How to print MS Access OLE Word Document using automation

I have an Access table that includes an OLE field containing an MS word document.   Presently I export information from this table and import it into a Word document for reporting purposes (using automation).  However  I am not including the OLE Word field but now wish to do so.  I need a copy of this embedded word file to include in my existing word report  but cannot see how to do this.
 
BethWoodhouseAsked:
Who is Participating?
 
BethWoodhouseConnect With a Mentor Author Commented:
Thanks but I have found what I need on the microsoft site.  I will now close the question, thanks all the same.
 

Sub CopyDocument_Click ()
          Dim NewObject As Object
          Dim NewDoc As String
          Dim DocPath As String

          ' Name of the new document to create.
          NewDoc = "TEST.DOC"

          ' Where to store the new document.
          ' DefaultDir$(9) returns the Word directory path.
          ' See DefaultDir$() in Word's on-line help for more options.
          ' Note: The "$" is not used when calling DefaultDir via
          ' OLE Automation.
          DocPath = Me!MyOle.Object.Application.WordBasic.DefaultDir(9)

          ' Copies the embedded object to Clipboard.
          Me!MyOle.Verb = 0
          Me!MyOle.Action = 7
          Me!MyOle.Object.Application.WordBasic.EditSelectAll
          Me!MyOle.Object.Application.WordBasic.EditCopy
          Me!MyOle.Action = 9
          DoEvents

          ' Creates a new document and pastes Clipboard contents.
          ' Saves the document in the Word directory and closes the
          ' document.
          Set NewObject = CreateObject("Word.Basic")
          NewObject.FileNew
          NewObject.EditPaste
          NewObject.FileSaveAs DocPath & "\" & NewDoc
          NewObject.FileClose

          ' Frees the memory used by the objects.
          Set NewObject = Nothing
          MsgBox DocPath & "\" & NewDoc & " was created successfully."
      End Sub
0
 
Jeffrey CoachmanMIS LiasonCommented:
BethWoodhouse,

Can I ask why you don't do your reporting in Access?
Thus avoiding all this OLE "Round-Tripping"

JeffCoachman
0
 
BethWoodhouseAuthor Commented:
Because it is an existing system that reports in word by exporting and doing a merge and I want to add more data to it.  However I would still like to know how to print the OLE contents in Access!
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
Jeffrey CoachmanMIS LiasonCommented:
OK
0
 
BethWoodhouseAuthor Commented:
I cannot see anything! Did you forget a link or an attachment?
0
 
Jeffrey CoachmanMIS LiasonCommented:
No, I was just saying OK.
0
All Courses

From novice to tech pro — start learning today.