Solved

How to print MS Access OLE Word Document using automation

Posted on 2008-10-24
6
544 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

 

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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…

751 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