Page 1 of 2 12 LastLast
Results 1 to 15 of 20
  1. #1
    2 Star Lounger
    Join Date
    Mar 2003
    Location
    London, Gtr London
    Posts
    131
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Opening Word from Access (2003)

    I have looked through the old posts and found a thread that has helped me get the code I think I need to open a Word document from Access. I have modified it slightly but I need to run this code from a command button, I used this code which I thought would work

    Private Sub cmdNotes_Click()
    Call OpenWordDoc("U:Global InformationUser ManualsExpenseTracking.doc")
    End Sub

    Public Sub OpenWordDoc(strFilePath As String)
    Dim appWord As Word.Application
    Dim doc As Word.Document
    strFilePath = "U:Global InformationUser ManualsExpenseTracking.doc"
    Set appWord = New Word.Application
    Set doc = appWord.Documents.Open(strFilePath)
    appWord.Visible = True
    appWord.Activate
    Set appWord = Nothing
    Set doc = Nothing
    End Sub


    Now I'm getting a new error:

    Compile Error:
    User-defined type not defined.

    Where am I going wrong?

  2. #2
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Opening Word from Access (2003)

    Which line or you getting the error on? Do you have a reference set to the Word object library?
    Charlotte

  3. #3
    2 Star Lounger
    Join Date
    Mar 2003
    Location
    London, Gtr London
    Posts
    131
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Opening Word from Access (2003)

    Oops sorry, its this line:

    Set appWord = New Word.Application

    I have set a reference to the Word object library.

    I also getting this message now (attachment)

    rgds
    Hayden

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

    Re: Opening Word from Access (2003)

    Try replacing

    Set appWord = New Word.Application

    with

    Set appWord = CreateObject("Word.Application")

  5. #5
    2 Star Lounger
    Join Date
    Mar 2003
    Location
    London, Gtr London
    Posts
    131
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Opening Word from Access (2003)

    Thanks Hans

    I have replaced the code as you suggest but I'm still getting an error.

    Unfortunately I can't get my screen dump smaller than 100k otherwise I would have attached it.

    But just to confirm:
    I have set a reference to Microsoft Word 11.0 Object Library
    The error I'm getting is: Run time error '-2147024770 (8007007e)': Automation error The specified module could not be found. For this line in the code: Set appWord = CreateObject("Word.Application")
    What I'm trying to do, is enable the user to open a word document which contains a user manual for the database they are using. If there is a better way than this I would be interested to learn about it.

    Many thanks again
    Hayden

  6. #6
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Sint Niklaas, Belgium
    Posts
    2,778
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Opening Word from Access (2003)

    If you want, you can send the db to me (see my profile). I'll see if I can find something.
    Francois

  7. #7
    2 Star Lounger
    Join Date
    Mar 2003
    Location
    London, Gtr London
    Posts
    131
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Opening Word from Access (2003)

    Francois, that's very kind of you, it's on it's way.

    Regards
    Hayden

  8. #8
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Sint Niklaas, Belgium
    Posts
    2,778
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Opening Word from Access (2003)

    Hayden,

    I tested your db on my pc. I had no problem to run it. Word document, after changing the path and file name to an existing doc on my pc, was opening as expected.
    Doing a google search on the error message you receive, I found a lot of stuff about error 2147024770, all referring to missing dll files. But nowhere there is an explicit name of the dll file.

    Can you try to do a detect and repair of office ?
    In the Help menu select Detect and Repair and see what's the result.
    You'll need the office cd's.
    Francois

  9. #9
    2 Star Lounger
    Join Date
    Mar 2003
    Location
    London, Gtr London
    Posts
    131
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Opening Word from Access (2003)

    Thanks Francois

    I'll give this a try and let you know what happens.

    Regards
    Hayden

  10. #10
    2 Star Lounger
    Join Date
    Mar 2003
    Location
    London, Gtr London
    Posts
    131
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Opening Word from Access (2003)

    Right, I have done what you suggested and I'm still getting the same error.

    I ticked the "Restore my shortcuts while repairing" box and a Pop up box saying "Setup completed successfully" appeared. I rebooted the machine and tried the button, which didn't work.

    There is another option on the repair menu, which wasn't ticked when I open the menu, which says "Discard my customized settings and restore default settings". Is it worthwhile ticking this and running the repair again?

    Regards
    Hayden

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

    Re: Opening Word from Access (2003)

    I don't think custom settings have anything to do with your problem. It seems that VB cannot find the Word object library. Do you have multiple versions of Word on your PC? (MS Office, MS Works)

  12. #12
    2 Star Lounger
    Join Date
    Mar 2003
    Location
    London, Gtr London
    Posts
    131
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Opening Word from Access (2003)

    Hi Hans

    No I only have MS Office Professional 2003 installed.

    Regards
    Hayden

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

    Re: Opening Word from Access (2003)

    Your code is OK (and it works on Francois' PC). You might test this further by copying the database and Word doc to another PC. Since a Detect and Repair didn't work on the problem PC, you may have to uninstall and reinstall Office 2003.

  14. #14
    2 Star Lounger
    Join Date
    Mar 2003
    Location
    London, Gtr London
    Posts
    131
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Opening Word from Access (2003)

    OK Hans,

    Thanks for the tip, will let you know what happens.

    Regards
    Hayden

  15. #15
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Sint Niklaas, Belgium
    Posts
    2,778
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Opening Word from Access (2003)

    Before uninstalling, maybe you can try to re-register the Word Object Library.
    Have a look at MSKB article 292744 to find out how to do this.
    Francois

Page 1 of 2 12 LastLast

Posting Permissions

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