Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

mail merge from ms access to ms word vba

jgolba99jgolba99 Posts: 9Member
Hello everyone I am trying to create a program that when you click a button it sends a mail merge to word and replaces all the bookmarks that I have setup. I am using 2010 for both products. I have pretty much everything done, but I am not sure how to have it open a document using a template. This is being done with vba. Right now it just opens the template and I don't really want that happening because I don't want anyone to save over the template. Here is the code that I have. I have only included the front end the rest of the code is just replacing the bookmarks.

Private Sub cmdPrint_Click()
Dim MyWord As Word.Application
Dim PathDocu As String


If Me.LawFirmName <> "" Then
Set MyWord = New Word.Application
PathDocu = "C:Word Template"

With MyWord

.Visible = True
.Documents.Open (PathDocu & "MailerTemp.dotx")

Thanks in advance for the help.

Comments

  • jgolba99jgolba99 Posts: 9Member
    I found the answer elsewhere and I figured I would post a response so that if anyone else had this issue they could find it here.

    Private Sub cmdPrint_Click()
    Dim MyWord As Word.Application
    Dim PathDocu As String


    If Me.LawFirmName <> "" Then
    Set MyWord = New Word.Application
    PathDocu = "C:Word Template"

    With MyWord

    .Visible = True
    .Documents.Open (PathDocu & "MailerTemp.dotx")


    This is the original post question and the answer is to change this portion .Visible = True
    .Documents.Open (PathDocu & "MailerTemp.dotx")

    If you change the .Open to .Add it will open a new document using the template.
Sign In or Register to comment.