I am looking for help regarding extraction of comments.
I want to use Excel to perform batch processing on several files, but I am unable to pass on the comments from X-change to Excel.
My idea was to use something like this:
Code: Select all
Const bolWaitOnReturn As Boolean = True
Const intWindowStyle As Integer = 0
Const strJScode As String = "C:\...\JavaScriptExample.txt"
Const strFullPathToProgram As String = "C:\Program Files\Tracker Software\PDF Viewer\PDFXCview.exe"
Dim objWsh As Object
Dim i As Integer
Dim strCmd As String
Set objWsh = VBA.CreateObject("WScript.Shell")
For i = 0 To frmPDFCommentExtract.lsbFilesList.ListCount - 1
'based on X-Change command line options
'If the pathname contains space, it shall be enclosed in quotes """"
strCmd = """" & strFullPathToProgram & """" & " " & _
"/runjs" & "" & _
":showui" & " " & _
"""" & strJScode & """" & " " & _
"""" & frmPDFCommentExtract.lsbFilesList.List(i) & """"
objWsh.Run strCmd, intWindowStyle, bolWaitOnReturn
Next i
(sorry for the poor javascript, this is the first time ever that I use this language)
Code: Select all
function addslashes(ch) {
ch = ch.replace(/'/g,"\'")
ch = ch.replace(" "," ")
ch = ch.replace(" "," ")
return ch
}
var annots = this.getAnnots({nSortBy: ANSB_Page});
if ( annots != null ) {
var CommentsList = "";
var msg = "%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n";
for (var i = 0; i < annots.length; i++)
var CommentsList = CommentsList + util.printf(msg, "!!PAGE!!", annots[i].page, "!!ID!!", annots[i].name, "!!ANSWER TO!!", annots[i].inReplyTo, "!!AUTHOR!!", annots[i].author, "!!CREATION DATE!!", annots[i].creationDate, "!!COMMENT!!", addslashes(annots[i].contents));
} else
var CommentsList = " No annotations in this document.";
var OutputFilename = this.documentFileName+"CommentsSummary.txt"
this.createDataObject(OutputFilename, CommentsList);
this.exportDataObject({ cName:OutputFilename, nLaunch:'2'});
//this.closeDoc(true)
My problem is that this.exportDataObject creates the textfile as an attachment to the pdf file and I am unable to pass on its content to Excel.
In fact, the macro above launch the scrip, but this leads to an open textfile and I have to manually close it to allow Excel to increment i and process with the next file.
For now on I can't figure on how to solve this issue.
Do you have any idea?
Thanks in advance !