I have to merge a high number of .doc files and print the result to PDF. At the same time, I need to keep different datas of the .doc files to create bookmarks for the PDF files : for example, one of my .doc’s name is 890331.doc and it contains 36 pages : my bookmark will be “Friday, 29 March 1989 - 36 p.” in the PDF file.
Is there another solution to get the number of pages of each .doc. Presently, I have not succeeded in getting back it with Visual Basic and found another means, see below,(not very smart technically speaking !..)
Could someone tell me why I can’t get NbdePages with :
do Visual Basic “NbdePages = ActiveDocument.ComputeStatistics(Statistic:=wdStatisticPages)”
And, more generally, how to get a variable from Visual Basic ?
(NB : I must merge the .doc files before printing to PDF because I haven’t succeeded in changing the page setup with do Visual Basic " With ActiveDocument.PageSetup …" ) : I can’t set the “Landscape” orientation in the PDFwriter.
Thank you in advance for all your help,
Here is the handler that “works” but is not technically so smart :
on getnbpage(Filename)
tell application "Microsoft Word"
activate
open (Filename)
do Visual Basic " Selection.WholeStory"
copy
---NbdePages = ActiveDocument.ComputeStatistics(Statistic:=wdStatisticPages)
do Visual Basic " If ActiveWindow.View.SplitSpecial = wdPaneNone Then
ActiveWindow.ActivePane.View.Type = wdPageView
Else
ActiveWindow.View.Type = wdPageView
End If"
do Visual Basic " Selection.EndKey Unit:=wdStory"
set contents of selection to "MesPages"
do Visual Basic " Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, Text:= _
"NUMPAGES ", PreserveFormatting:=True"
set toto to (get last word)
close document Filename saving no
end tell
return toto as string
end getnbpage