Results 1 to 5 of 5
  1. #1
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Canada
    Posts
    284
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Problem Opening Word from Access (Access 2000)

    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. <font color=magenta>**THE PROBLEM IS THIS LINE.</font color=magenta>
    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?

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Problem Opening Word from Access (Access 2000)

    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.

  3. #3
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Canada
    Posts
    284
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Problem Opening Word from Access (Access 2000)

    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!

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Problem Opening Word from Access (Access 2000)

    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.

  5. #5
    2 Star Lounger
    Join Date
    Jun 2004
    Location
    L, Schleswig-Holstein, Germany
    Posts
    184
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Problem Opening Word from Access (Access 2000)

    (Edited by HansV to make URL clickable - see <!help=19>Help 19<!/help>)

    Hmm I know your problem is solved but it's always good to have many solutions [img]/forums/images/smilies/wink.gif[/img]

    Take a peek at this example: http://www.microsoft-accesssolutions...n_word_doc.htm

    Dennis

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •