September 27, 200718 yr I am trying to create a Visual Basic Mail Merge script that opens a predefined word document located in: (C:Documents and SettingsAll UsersTemplatesmailMergeTemp.doc), which has a mail merge data file already attached and is located in: (C:Documents and SettingsAll UsersTemplatesmMailMailMergeData.mer). The script below opens the word document but fails to exicute the mail merge command and i have to exicute it manualy by clicking on the Merge to New Document button. Any Ideas? Set objWord = GetObject("C:Documents and SettingsAll UsersTemplatesmailMergeTemp.doc", "Word.Document") ' 'Make Word visible. objWord.Application.Visible = True ' 'Make Microsoft Word active application Set WshShell = CreateObject("WScript.Shell") WshShell.AppActivate "Microsoft Word" ' 'Run Mail Merge With objWord.MailMerge .Destination = wdSendToNewDocument .SuppressBlankLines = True With .DataSource .FirstRecord = wdDefaultFirstRecord .LastRecord = wdDefaultLastRecord End With End With
Create an account or sign in to comment