Discussion Locked

To open files in directory in succession

0 helpful
5 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

I'm a fledgling VBA user in MSOffice and have developed a macro to format and print the current document.

How would I develop a procedure to successively open each document in a directory, take the formatting options, print and close (without saving) the document, and continue with the next document?

5 replies

by jmiller1

Use the DIR() function to search through a directory for a particular file pattern (*.doc, *.xls, etc), open the document, use the workbook.printout function to print the document, and then use workbook.close (false) to close the document without prompting for a save.

by rrv

Use Dir function to get all the files.
For each file in that directory if file is not VBDirectory then open it, format and print. you can display options using Dialogs. Example if it is Excel, ExlObj.Dialogs.

for formatting options use the Setup method or property of the Office automation server.[word or excel].

All the best
Raja venkatesh

This discussion is closed to new replies.