Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Inserting MS Word document into a report at runtime

Status
Not open for further replies.

billlagr

Programmer
Apr 28, 2011
9
AU
Hi All
I have a report that is run monthly, however I would like a short Word doc inserted into the report. The doc changes from month to month, so my original plan was to place an unbound object frame in the report, then at run time open a file chooser dialog so the user could select the doc, then change the .SourceDoc property of the object frome to point to the selected file.
However, I can't get this to work - the file dialog works, returns the correct path and file name, however the object frame does not update. If I try to add .Action = acOLEUpdate, I get an error that there is no OLE object to update.
Doing a similar thing within a form works fine, however it doesn't with a report - anyone have any ideas?

Thanks
Bill
 
Unless you are opening the report in design view before you run the report, I don't think it will work.
 
I have changed things a bit, and now open the report in design view, add an unbound object frame, set the .Sourcedoc as appropriate..but it still fails at the .Action part. How can I force the frame to update and display the contents of the word doc?
This is what I have so far -

DoCmd.OpenReport "Monthly Error Report", acViewDesign
Set WordDoc = CreateReportControl("Monthly Error Report", acObjectFrame, acDetail, "", "", 500, 4500, 9800, 9000)

With WordDoc
.Name = "ImportedWordDoc"
'.OLEType = acOLELinked
.OLETypeAllowed = acOLELinked
.OLEClass = "Microsoft Word"
.Class = "word.document"
.SourceDoc = LetterFileName
'.Action = acOLEActivate
End With

.OLEtype causes an error (This property is read-only) and .Action causes -
'The bound or unbound frame you tried to edit dosen;t contain an OLE object'

Am I missing something?
 
I'd have the object frame in the report and just set the sourcedoc property of it. Don't forget to save the report.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top