Results 1 to 2 of 2
  1. #1
    4 Star Lounger
    Join Date
    Apr 2001
    Posts
    482
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Inserting, opening, and closing an object > IPF (Word 2000 VBA)

    I'm trying to insert an existing Microsoft Word Document Object, then open the object (so I can adjust some of the text in the object), and then close it again. However, when I get to the step of closing the document, I get the following error:

    I was getting the following error when I stepped through the macro at the step of closing the document object, but now I just get it if I run it from Tools>Macro>Macros:

    WINWORD caused an invalid page fault in
    module MSO9.DLL at 017f:308f8a93.

    Now for some reason I am getting the following two IPF's when I try to step through it after reaching the end of the sub and hitting the ALT key or trying to view the document again (since steping through is done in the VBA editor):

    WINWORD caused an invalid page fault in
    module <unknown> at 0000:00000007.

    WINWORD caused an invalid page fault in
    module WINWORD.EXE at 017f:30127d8e.

    I looked at the knowledge base articles on Microsoft's sight, but none seemed to apply to my situation. I tried some of the fixes they recommended as well, but to know avail. I also check the references to mso9 on this forum, but could not find my situation.

    As I have the macro so far, all I am doing is opening and then immediately closing the object.

    'This is the code I am using to insert the object:
    Selection.InlineShapes.AddOLEObject ClassType:="Word.Document.8", FileName _
    :="E:My DocumentsGoalsObject.doc", LinkToFile:=False, DisplayAsIcon _
    :=False

    (I have tried changing "Word.Document.8" to "Word.Document.9", but it does not make a difference.)

    'This is the code I am using to open the object after I select it:
    Selection.InlineShapes(1).OLEFormat.DoVerb VerbIndex:=1

    'This is the code I am using to close the object (and also where the error occurs):
    ActiveDocument.Close

    I tried to copy just this module to a separate document and run it, but I don't get the error message. I have tested and tested and beat my head against the wall a few times <img src=/S/bash.gif border=0 alt=bash width=35 height=39>, and I still can't figure out why I cannot reproduce the problem outside this document.

    I have not run any other procedure before running this macro, so I cannot figure out why it makes a difference to have only this procedure in a document. I am baffled.

    Also, it would be nice if I could use a relative path, but when I put the object in the same directory as my main document containing the macro, it tells me "Word cannot obtain the data for the Object.doc.lnk".

    The code when trying this looks like this:

    Selection.InlineShapes.AddOLEObject ClassType:="Word.Document.8", FileName _
    :="Object.doc", LinkToFile:=False, DisplayAsIcon _
    :=False

    Please help!!
    Troy

  2. #2
    4 Star Lounger
    Join Date
    Apr 2001
    Posts
    482
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Inserting, opening, and closing an object > IPF (Word 2000 VBA)

    F.Y.I. just in case this happens to you, I thought I would share what appears to be the fix for this, even though I don't know for sure the cause. Perhaps there was some document corruption.

    I ended up exporting all my forms and modules, and then importing them into a new clean document. The new document does not exhibit the errors of the other document.

    Hope this helps someone else!!
    Troy

Posting Permissions

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