none
Open Word document stored in a table as OLE object. RRS feed

  • Question

  • I have an Access db, and save Word document in a table. I have saved this as OLE object. I want to open these individually from buttons In form using VBA code. How do I do this?
    -Egil
    Tuesday, November 24, 2015 3:10 PM

Answers

  • >>>I have an Access db, and save Word document in a table. I have saved this as OLE object. I want to open these individually from buttons In form using VBA code. How do I do this?

    According to your description, you could refer to below code:

    Dim WordObj As Object    
    Me![Doc].Verb = -2   ' Tells Microsoft Access to open the application.
    Me![Doc].Action = 7  ' Activates the application.
    Set WordObj = Me![Doc].Object.Application.WordBasic
    WordObj.AppShow

    For more information, click here to refer about ACC: How to Open and Close Word Documents with OLE Automation

    Wednesday, November 25, 2015 2:19 AM

All replies

  • You can store the path to the file more efficiently in a text column in the table rather than an OLE column.  Take a look at BrowseDemo.zip in my public databases folder at:

    https://onedrive.live.com/?cid=44CC60D7FEA42912&id=44CC60D7FEA42912!169

    If you have difficulty opening the link copy its text (NB, not the link location) and paste it into your browser's address bar.

    This little demo file allows you to browse to a file and add assign the path to a text box control in the form.  The form in my demo is unbound, but it could equally well be bound to a table of course.

    The file can be opened by clicking on the path, which is formatted as a hyperlink.  The control's Click event procedure simple calls the Click event procedure of the cmdOpen button.  Alternatively you can click the button.  You can also print the file via the cmdPrintFile button.

    The file is opened or printed by calling the Widows API ShellExecute function.

    Ken Sheridan, Stafford, England

    Tuesday, November 24, 2015 4:20 PM
  • >>>I have an Access db, and save Word document in a table. I have saved this as OLE object. I want to open these individually from buttons In form using VBA code. How do I do this?

    According to your description, you could refer to below code:

    Dim WordObj As Object    
    Me![Doc].Verb = -2   ' Tells Microsoft Access to open the application.
    Me![Doc].Action = 7  ' Activates the application.
    Set WordObj = Me![Doc].Object.Application.WordBasic
    WordObj.AppShow

    For more information, click here to refer about ACC: How to Open and Close Word Documents with OLE Automation

    Wednesday, November 25, 2015 2:19 AM