When a MS-Access 2003 VBA script tried to open MS-Word and run the mail merge function, VBA displayed this error message:
Run-time error '5922': Word was unable to open the data source
The problem was tracked to this statement:
Dim objWordApp As Object Set objWordApp = CreateObject("Word.Application") With objWordApp ... .ActiveDocument.MailMerge.OpenDataSource Name:=CurrentDb.Name, SQLStatement:=sQuery, SubType:=wdMergeSubTypeWord2000
There's plenty of different solutions to this problem on the web. In this case, the problem was due to the second argument, the SQL query, sQuery, which had an error.
I spent some time browsing the web to investigate the run-time error, when it would have been more effective to first check the arguments in the subroutine call. Live and learn.
No comments:
Post a Comment