A couple of additions to Doug's post: If you want to specify the data source file on the command line
a. your macro will need to get the complete command line using whatever facilities are available (you may need to use a Win32 function to do it).
b. because Word tries to find any attached data source before it even executes things such as AutoNew and AutoOpen, and because you cannot trap the error if the data source is not present or is invalid, you must either
- ensure that the data source the document expects is there. Once Word has attached it, your macro can change it or
- detach the document/template from the data source before you save it, i.e. set the document/template to be a "Normal Word document". You will lose any sort or filter parameters, but MERGEFIELD and other merge-related fields should still remain.
--
Peter Jamieson
Is it possible to issue a command from the command line that would load a Word template file (.dot) and automatically merge it with a text data file (.txt) and display the merged result to the user?
PMC