Results 1 to 2 of 2
  1. #1
    Slant is offline Novice
    Windows XP Access 2003
    Join Date
    Jul 2010
    Posts
    2

    Open word doc from vba strips doc of merge-ability

    Hi all,



    First post. Thanks in advance for any help you can provide.

    In my Access app (Access 2003), I'm trying to add a command button that launches a specific Word document. Following is my code, which works fine:

    Dim LWordDoc As String
    Dim oApp As Object

    'Path to the word document
    LWordDoc = "my_path\my_doc.doc"

    Set oApp = CreateObject(Class:="Word.Application")
    oApp.Visible = True

    'Open the Document
    oApp.Documents.Open FileName:=LWordDoc

    End Sub

    When I press the command button the document launches as it should. However, this Word doc is a merge document, which draws data from a query that happens to be connected to this same Access app. When the Word doc launches I'm no longer presented with the "approve SQL data" dialog box. Instead, it just opens. The merge fields are still on the document, but it seems the connection to the query is no longer in place.

    Any ideas?

    Thanks!
    Last edited by Slant; 07-29-2010 at 01:32 PM.

  2. #2
    pkstormy's Avatar
    pkstormy is offline Access/SQL Server Expert
    Windows XP Access 2003
    Join Date
    Mar 2010
    Location
    Madison
    Posts
    682
    Try this:

    Dim strFileName as variant
    strFileName = "my_path\my_doc.doc" (<- missing drive name or correct UNC path)
    Application.FollowHyperlink strFileName

    This will open the document correctly. But you need to define the correct drive/folder/filename as indicated above (or use the correct UNC name.)

    ex:
    Dim strFileName as variant
    strFileName = "F:\my_path\my_doc.doc"
    Application.FollowHyperlink strFileName

    As far as the merge fields, you'll need to make sure the word document can "see" the mdb/mde/accdb/accde file and the query.

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

Similar Threads

  1. Access / Word mail merge problem.
    By PD1117 in forum Access
    Replies: 0
    Last Post: 07-06-2010, 09:41 AM
  2. Open a word dotx from acess
    By frcastro in forum Access
    Replies: 9
    Last Post: 06-17-2010, 12:56 PM
  3. Open Word Doc in foreground
    By patrickmcdiver in forum Programming
    Replies: 1
    Last Post: 03-02-2010, 12:26 AM
  4. Name Merge
    By leejqs in forum Reports
    Replies: 3
    Last Post: 07-16-2009, 07:02 AM
  5. Mail Merge from Access to Word
    By Rachelkm2 in forum Programming
    Replies: 1
    Last Post: 05-29-2009, 02:49 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