Results 1 to 2 of 2
  1. #1
    journeyman is offline Advanced Beginner
    Windows 11 Access 2016
    Join Date
    Dec 2022
    Posts
    82

    Word Document closing class

    Hi all



    I am attempting to detect when a word document I've opened via MS Access module was closed.
    The purpose is to open document via a form (OLE), modify it, close it and refresh the OLE. it only does this with an embedded OLE object but not with a linked OLE, so I'm trying to use the close event to refresh the ole control. (plus to capture other details about the document).

    I've considered that the best way to do this is through a class

    In my Class module (Cls_Word):

    Code:
    Option Explicit
    Public WithEvents DocItem As Word.Document
    Private Sub DocItem_Close()
      MsgBox "The document is closed."
    End Sub
    In my Module (Mod_Word)
    Code:
    Option Explicit
    Public wrdEvents As Cls_Word
    Sub SetDoc()
    Dim wrdApp As Word.Application
    Dim wrdDoc As Word.Document
            Set wrdApp = CreateObject("Word.Application")
            Set wrdDoc = wrdApp.Documents.Open(FileName:=strDocPath, ReadOnly:=False)
            Set wrdEvents.DocItem = wrdDoc ' This generates a err.number: 91 err.description: Object variable not set.
    End Sub
    What am I missing? Or have I gone off the rails completely

  2. #2
    journeyman is offline Advanced Beginner
    Windows 11 Access 2016
    Join Date
    Dec 2022
    Posts
    82
    Closing - I never did work out how to get that class to work (which would have been helpful to know), but the OLE object Seems to refresh if it's linked correctly.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Recordset to Word Document
    By DMT Dave in forum Access
    Replies: 1
    Last Post: 08-06-2020, 08:34 AM
  2. Imported word document
    By Xypopcorn in forum Import/Export Data
    Replies: 1
    Last Post: 01-12-2020, 05:49 AM
  3. Replies: 3
    Last Post: 06-27-2017, 12:06 PM
  4. Closing Word Document From Access
    By bburton in forum Programming
    Replies: 2
    Last Post: 04-25-2011, 10:23 AM
  5. Import Word document using VBA
    By degras in forum Import/Export Data
    Replies: 4
    Last Post: 04-12-2011, 02:40 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums