• Intercept Document_Open (Win XP Word 2003)

    Home » Forums » AskWoody support » Productivity software by function » MS Word and word processing help » Intercept Document_Open (Win XP Word 2003)

    • This topic has 7 replies, 2 voices, and was last updated 21 years ago.
    Author
    Topic
    #404285

    I have a global template in Word’s the startup folder.

    I know I can do so if I have a .dot file in which I place a procedure called “Document_Open()” and the code inside this will execute when a document is opened.

    But… How can I write a procedure in the global template that intercepts opening a document?
    It does not work with “Document_Open()”.

    Rgds
    Bj

    Viewing 3 reply threads
    Author
    Replies
    • #821243

      You need an application-level event handler for DocumentOpen for this. See post 320550 for an example. But if I remember correctly, you are using some kind of document retrieval system, and that might well interfere with the application-level event handler. I don’t know how to solve that.

      • #821263

        (This may be a double post, I answered on Post: 320550)

        Thanks Hans!

        I have tried this but cannot get it working.

        <Public Sub FixDoc(doc As Document)
        < With doc.ActiveWindow
        < .DocumentMap = True ' What exactly does these two methods?
        < .DocumentMap = False
        < End With
        <End Sub

        <3. Put the following code in ThisDocument: ' I presume "ThisDocument" is the module "ThisDocument" in the Global template?
        The document I'm opening does not have areference to a .dot file and thus cannot know anything about the code.

        This procedure in "ThisDocument" will not run:
        Private Sub Document_Open()
        Set myCls.app = Application
        MsgBox "Open works"
        End Sub

        Rgds
        Bj

    • #821244

      You need an application-level event handler for DocumentOpen for this. See post 320550 for an example. But if I remember correctly, you are using some kind of document retrieval system, and that might well interfere with the application-level event handler. I don’t know how to solve that.

    • #821319

      Discussion has been continued in post 367892 and further. I am locking this thread to avoid confusion and duplication.

    • #821320

      Discussion has been continued in post 367892 and further. I am locking this thread to avoid confusion and duplication.

    Viewing 3 reply threads
    Reply To: Intercept Document_Open (Win XP Word 2003)

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

    Your information: