Link to home
Start Free TrialLog in
Avatar of Roger
RogerFlag for United Kingdom of Great Britain and Northern Ireland

asked on

VBA automation: to append many word files into one PDF file

I have an increasing number (~60) of 1-2 page word files, and seek VBA automation to convert/append each word file, in a chosen order, into a single PDF file. Each appended word file should begin a new page in the pdf.

The word fileNames are listed in an xl sheet, together with their ORDER of occurrence in the PDF file.

As the word files proliferate in number, the ORDER value will enable me to shift word files into the most helpful order in the single PDF file.

The speed of assembly of the PDF is not very important, as the final PDF file will be distributed as such.

Thanks, Kelvin
ASKER CERTIFIED SOLUTION
Avatar of GrahamSkan
GrahamSkan
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Roger

ASKER

Graham:
Thanks for this speedy and response which should push me on quicker.
It will be two days before I can test it, so I'll pay up the points now and let you know how I get on.

Much appreciated
Kelvin
Avatar of Roger

ASKER

Graham:
It worked exactly as you said, thanks!
If I may ask one brief question?? - can you give a pointer to using vba to count the number of pages in a word or pdf document?

Cheers/
Kelvin
Can't help with PDF, but with Word documents you can use:
iPageCount = ActiveDocument.Range.Information(wdNumberOfPagesInDocument)

Open in new window

Avatar of Roger

ASKER

Thanks: that did it fine!
Avatar of Roger

ASKER

Graham:
A strange bug has appeared in the code you sent me, and the same occurred even when I re-pasted your original code into a new xl file. The problem follows the successful sorting of word file name data in "sheet1", its outcome is the the piece reports that the word file named in Row 1 of "Sheet1" cannot be found. However all the five word files to 'read' into the PDF file are present in the requisit folder, and their content is unchanged.

Word vba syntax is quite new to me, though I have made some progress toward reading the page number value for each word file.

 I'd like to ask you to comment on how I went about this.

SO! As this is new ground, i thought I'd issue these issues as a NEW question, and give you prior warning. Trust that is acceptable?  I will load the new question in 2 hours from now, when I've assembled the files, and done a final check...

regards,
Kelvin