• Problem Opening Word from Access (Access 2000)

    Home » Forums » AskWoody support » Productivity software by function » MS Access and database help » Problem Opening Word from Access (Access 2000)

    Author
    Topic
    #407819

    I had this working at one time, now I can’t figure out what I did wrong. I have the following code:

    Function MergeIt()

    Dim objWord As Word.Document
    Set objWord = GetObject(“G:Student Fees ProgramCCHSMySchoolFeesHelpStudentLabels5162.doc”, “Word.Document”)
    ‘ Make Word visible. **THE PROBLEM IS THIS LINE.
    objWord.Application.Visible = True
    ‘ Set the mail merge data source as the WorkingCopy database.
    objWord.MailMerge.OpenDataSource _
    Name:=”G:Student Fees ProgramCCHSMySchoolFeesHelpWorkingCopy.mdb”, _
    LinkToSource:=True, _
    Connection:=”QUERY Labels Query”
    ‘ Execute the mail merge.
    objWord.MailMerge.Destination = wdSendToNewDocument
    objWord.MailMerge.Execute
    Set objWord = Nothing

    End Function

    The problem is the line ” Set objWord = GetObject(“G:Student Fees ProgramCCHSMySchoolFeesHelpStudentLabels5162.doc”, “Word.Document”). When I run this, I get a “Run-time error ‘-2147467259(80004005)’: Automation error Unspecified error”. What does this mean?

    Viewing 3 reply threads
    Author
    Replies
    • #856048

      Is the document you try to open already the main document for a mail merge? If so, Word could have trouble locating the data source.

      • #856083

        Thanks, Hans. I just went into my Word document, and that’s where the problem was. I had to connect with the correct data source again. Works great now!

        • #856087

          An alternative I often use is to restore the document to a non-merge document (in the first step of the mail merge helper), then save it. This will make the document open much faster, since Word won’t have to search for the data source. You set the data source in code anyway, so the merge will still work fine.

        • #856088

          An alternative I often use is to restore the document to a non-merge document (in the first step of the mail merge helper), then save it. This will make the document open much faster, since Word won’t have to search for the data source. You set the data source in code anyway, so the merge will still work fine.

      • #856084

        Thanks, Hans. I just went into my Word document, and that’s where the problem was. I had to connect with the correct data source again. Works great now!

    • #856049

      Is the document you try to open already the main document for a mail merge? If so, Word could have trouble locating the data source.

    • #856170

      (Edited by HansV to make URL clickable – see Help 19)

      Hmm I know your problem is solved but it’s always good to have many solutions

      Take a peek at this example: http://www.microsoft-accesssolutions.co.uk/open_word_doc.htm%5B/url%5D

      Dennis

    • #856171

      (Edited by HansV to make URL clickable – see Help 19)

      Hmm I know your problem is solved but it’s always good to have many solutions

      Take a peek at this example: http://www.microsoft-accesssolutions.co.uk/open_word_doc.htm%5B/url%5D

      Dennis

    Viewing 3 reply threads
    Reply To: Problem Opening Word from Access (Access 2000)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: