Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VBA how to change document type for mailmerge

Status
Not open for further replies.

Assam83

Programmer
Sep 1, 2008
2
GB
Hi guys

im trying to change the MS Workd mailmerge document type in VBA from Access any ideas??

Thanks

current code:

'make sure there is data to merge
If (tbl.RecordCount > 0) Then

strDocName = "Additional_Forms.doc"
strNewName = "Last_Additional_Forms"

objWord.Application.Visible = True

Set objDoc = objWord.Documents.Open(strDir & strDocName)

'Make Word visible so that if any errors occur, you can close the instance of Word manually
objWord.Application.Visible = True

Call objDoc.MailMerge.OpenDataSource(Name:=strDir & strDB, LinkToSource:=True, Connection:="TABLE ECB_Additional_Forms_toSend", SQLstatement:="SELECT * FROM ECB_Additional_Forms_toSend", SubType:=wdMergeSubTypeWord2000)

'objDoc.MailMerge.Destination = wdSendToNewDocument
'objDoc.MailMerge.Execute

letters = True
End If
 
Hi Assam83,

Do you mean something like objDoc.SaveAs?
Because as long as MS Word is open it's a Word-document unless you save it as a different type.

Good luck
 
Morning,

The line of code I was after was:

objDoc.MailMerge.MainDocumentType = wdDirectory
'Changes the mailmerge document type to Directory

I needed to change the word document to this type for formatting purposes. Finally managed to get at it by hitting F2 and going through all the methods.

Thanks for your reply

Assam
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top