Chris Christou Posted September 27, 2007 Posted September 27, 2007 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
Recommended Posts
This topic is 6309 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now