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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Make Standard Toolbar Visible On Mail Merge .Dot 1

Status
Not open for further replies.

DomDom3

Programmer
Jan 11, 2006
59
GB
Hi there,

I'm passing this thread on on behalf of a friend. He uses the code below to mail merge to Word. I'm told the code works perfectly but when the .dot template is opened the standard toolbar is not on view.

I know that the code from within word is
"CommandBars("Standard").Visible = True"
But would this still be the code when operating from Access and where in the sub should it appear?

On Error Resume Next
Dim db As DAO.Database
Dim objWord As Word.Application
Dim TemplateChoice As String
Dim strMyTemplatePath As String

DoCmd.SetWarnings False
DoCmd.OpenQuery "qryCustomerInvoice"
DoCmd.SetWarnings True

Set db = CurrentDb()

Set objWord = GetObject(, "Word.Application")
If Err.Number <> 0 Then
Set objWord = CreateObject("Word.Application")
End If

objWord.Visible = True
'Code here to allow choice of Template

strMyTemplatePath = "C:\Invoice.dot"

objWord.Documents.Add Template:=strMyTemplatePath, NewTemplate:=False

objWord.ActiveDocument.MailMerge.OpenDataSource _
Name:=db.Name, _
LinkToSource:=True, _
Connection:="TABLE tblInvoice", _
SQLStatement:="Select * from [tblInvoice]"

objWord.ActiveDocument.MailMerge.Execute

Thanks

 
objWord.ActiveDocument.MailMerge.Execute
objWord.CommandBars("Standard").Visible = True

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top