Solved

How to print MS Access OLE Word Document using automation

Posted on 2008-10-24
6
522 Views
Last Modified: 2013-12-25
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.
 
0
Comment
Question by:BethWoodhouse
  • 3
  • 3
6 Comments
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 22801014
BethWoodhouse,

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

JeffCoachman
0
 

Author Comment

by:BethWoodhouse
ID: 22801783
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
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 22803910
OK
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

by:BethWoodhouse
ID: 22804941
I cannot see anything! Did you forget a link or an attachment?
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 22806202
No, I was just saying OK.
0
 

Accepted Solution

by:
BethWoodhouse earned 0 total points
ID: 22806561
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

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now