Results 1 to 9 of 9
  1. #1
    Lounger
    Join Date
    Dec 2002
    Posts
    35
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Automation Error (AccXP SP2)

    I have written an Access application which uses Automation and opens Word document from inside this application. All this works fine on Win2K/Acc2K where the application was developed, but the program does not work on Access XP, returning the message "Object is not connected to server". On Win2K/AccXP, the program even bombs out. I traced the procedure and found that the program gets the error when it comes to the line ".Execute FindText:= ...." Does anybody have any idea about this problem?

    Thanks

  2. #2
    Super Moderator
    Join Date
    Aug 2001
    Location
    Evergreen, CO, USA
    Posts
    6,624
    Thanks
    3
    Thanked 60 Times in 60 Posts

    Re: Automation Error (AccXP SP2)

    This is more or less conjecture, but you may need to check to see that you have the correct references (in particular to Word 10) in you code. There were also some changes in VBA and the support for legacy Word Basic in Word XP. Is this the first command where you attempt to do anything with the word document? If not, then I would suspect the problem is with the line you debugged to - otherwise it maybe that that Word is not happy being a server for some reason.
    Wendell

  3. #3
    Lounger
    Join Date
    Dec 2002
    Posts
    35
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Automation Error (AccXP SP2)

    Dear Wendell,

    Thanks for a quick reply. Yes, references are all correct. I refreshed them. Here is a portion of the program codes:

    Set wordObject = New Word.Application
    wordObject.Documents.Add TemplateFile

    wordObject.Selection.WholeStory
    Set rng = wordObject.Selection.Range

    With rng.Find
    .ClearFormatting
    .Execute FintText:="abc", Replacewith:="xyz", Replace:=wdReplaceAll
    End With

    wordObject.Visible = True
    Set wordObject = Nothing

    In the above codes,

    .Execute FintText:="abc", Replacewith:="xyz", Replace:=wdReplaceAll

    is where the program bombs out.

    As I was browsing around in MSDN, I found the following article, but wasn't sure if this applies to my problem. In that article, they suggest I re-register Word Library by running Regtlib.exe, but I could not find the program on my and my colleague's XP.

    http://support.microsoft.com/default.aspx?...kb;en-us;292744

    I would appreciate any further thoughts.

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

  4. #4
    3 Star Lounger
    Join Date
    Aug 2002
    Location
    Leuven, Vlaanderen, Belgium
    Posts
    322
    Thanks
    9
    Thanked 0 Times in 0 Posts

    Re: Automation Error (AccXP SP2)

    schlomos,
    I've never dealt with this problem and I'm no accustomed VBA-programmer, certainly not in XP but maybe this might be of some help:
    - late binding
    - reregister the Word type library on the system on which the problem occurs.
    I hope this is of some use...
    Hasse
    ps Source: http://www.experts-exchange.com/Applicatio...Q_20722227.html pointing to this Microsoft KB article: http://support.microsoft.com/default.aspx?...kb;en-us;292744

    URLs corrected by HansV

  5. #5
    3 Star Lounger
    Join Date
    Aug 2002
    Location
    Leuven, Vlaanderen, Belgium
    Posts
    322
    Thanks
    9
    Thanked 0 Times in 0 Posts

    Re: Automation Error (AccXP SP2)

    Hi,
    it seems you found the same article while I was writing about it <img src=/S/grin.gif border=0 alt=grin width=15 height=15>.
    Please notice that the required Regtlib.exe is to be found in something like a "Microsoft Libraries Update". Dunno where to find it but this MSKB article sited in the one above might be a step forward: http://support.microsoft.com/default.aspx?kbid=197298
    Good luck,
    Hasse

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

    Re: Automation Error (AccXP SP2)

    Hasse's suggestion of using late binding instead of early binding is spot on. I could reproduce the crash in a small test, but it works ok if you use the following:

    Dim wordObject As Object
    Dim rng As Object

    Set wordObject = CreateObject("Word.Application")

  7. #7
    Lounger
    Join Date
    Dec 2002
    Posts
    35
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Automation Error (AccXP SP2)

    Hasse and Hans,

    Thanks a lot. Late binding did work! (I didn't know exactly what this meant.)

    Best

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

    Re: Automation Error (AccXP SP2)

    Early binding means that you set a reference to the object library you're going to use (in this case, the Microsoft Office n.0 Object Library), and use this object library in the declaration:

    Dim wordObject As Word.Application

    By doing this, you can inspect the properties and the methods of the object in design time. If you type wordObject followed by a period (dot), IntelliSense will kick in and display a list of available properties and methods. You will get a compile error if you try to use a non-existent property or method.

    Late binding means that you don't specify the object type in the declaration:

    Dim wordObject As Object

    You won't be able to use IntelliSense, and non-existing properties and methods won't cause a compile error (but they will cause a runtime error.) You use CreateObject, which takes a string argument, to create the Word object; this is only resolved in runtime.

    In many cases, early binding is to be preferred, but sometimes you run into compatibility problems; this is apparently what happened to you. Then, late binding is better.

  9. #9
    Lounger
    Join Date
    Dec 2002
    Posts
    35
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Automation Error (AccXP SP2)

    Dear Hans,

    Thank you for your kind explanation of early-late binding. I bumped into this term often but ignored it (because I didn't understand it). Now I feel I got wiser a bit.

    shlomos

Posting Permissions

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