Jump to content
Server Maintenance This Week. ×

Visual Basic Mail Merge Script


This topic is 6057 days old. Please don't post here. Open a new topic instead.

Recommended Posts

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

Link to comment
Share on other sites

This topic is 6057 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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.