Results 1 to 3 of 3
  1. #1
    tanyad is offline Novice
    Windows XP Access 2007
    Join Date
    Apr 2012
    Posts
    2

    Open Word Template from Form Control

    Hi,
    I have a query which looks at the active form to identify the record I want to export to a Word Document:

    SELECT tblInterview.InterviewID, tblInterview.DateInterviewed, tblStudents.StudentNo, tblStudents.LastName, tblStudents.FirstName, tblStudents.ScholasticYear, tblInterview.InvoiceAmt
    FROM tblStudents INNER JOIN tblInterview ON tblStudents.StudentNo = tblInterview.StudentNo
    WHERE (((tblInterview.InterviewID)=[Forms]![frmSubInterview]) AND ((tblInterview.InvoiceStudent)=Yes));

    The word document is saved as a template file (.dotx) and is linked as a mail merge document to the above query.

    When I create a document from the template, it all works fine. My next problem is to create a control on my form [frmSubInterview] which will open MS Word, in particular the template, so that the document can be printed and then saved.

    Could someone please advise me.



    I've looked at several examples on the Internet but can't seem to get it to work.

    This attempt comes up with a compile error User-defined type not identified on the first line of code.:

    Private Sub CmdWord_Click()
    Dim wordApp As Word.Application
    Dim wordDoc As Word.Document
    Set wordApp = New Word.Application
    With wordApp
    .Visible = True
    Set wordDoc = .Documents.Open(".../DamagesTemplate.dotx", , False)
    End With
    End Sub

    Thanks in advance for any support.

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,816
    Do you have the Microsoft Word 12.0 Object Library selected in the VBA references? On VBA editor menu: Tools > References
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    tanyad is offline Novice
    Windows XP Access 2007
    Join Date
    Apr 2012
    Posts
    2
    Thank you. That solved the problem. I couldn't have done it without your showing me how to check MS Word 12.0 Object Library was selected.
    Also. Not sure how to close thread as solved.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Import Word Docs as Form Template
    By Spectre50 in forum Forms
    Replies: 0
    Last Post: 03-05-2012, 01:51 PM
  2. Command button to open email template
    By avarusbrightfyre in forum Import/Export Data
    Replies: 5
    Last Post: 09-10-2011, 11:18 AM
  3. vba code to populat word template in Access 2010
    By graffjohn in forum Programming
    Replies: 2
    Last Post: 06-11-2011, 09:36 PM
  4. Replies: 1
    Last Post: 05-20-2011, 07:42 AM
  5. Replies: 2
    Last Post: 04-15-2011, 01:13 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums