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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with export report to Word please

Status
Not open for further replies.

rob9740

Technical User
Nov 21, 2001
30
IE
Hi all,

I was wondering if anybody can help me with this. I'm trying to export a report to Word.
I've looked through the posts and found a few ideas and tried them but.....I can't seem to get them to work for me.

Basically I've a report that contains 4 sub-reports which are generated from queries. The main report is activated from a form control button which generates the sub-reports from the queries. When I try to export the main report to Word using "publish it with word" button but it asks me for the query criteria again.

Anybody have any suggestions on how to work around this cos I want to try and automate this process as well.

Any help\suggestions would be appreciated very highly.
Cheers,

Rob
 
Look up the DoCmd.OutputTo command and outputting to RTF format.

Craig
 
Cheers Craig, but it's still asking me for the query criteria that are passed to it by the form.
 
You could also send the data directly to MS Word.

Dim objWord as Object
'Create your recordset / run your queries

Set objWord = CreateObject("Word.Application")
objWord.Visible = True
objWord.Documents.Add 'This will open a new document
'NOW ADD YOUR DATA
Selection.TypeText Text:= "REPORT HEADER"

Do While Not rs.EOF
Selection.TypeText Text:= rs.Field(0)
Selection.TypeParagraph
Loop

ObjWord.Close
Set objWord = Nothing

You will need to select ensure that the MS Office Object Library is selected (can be found under Tools->References)

HTH,
jc
 
How does the selection variable work???
I'm presuming this won't put the format of the reports I've designed into Word.
I'm just wondering if it made a difference that the form is opening the report directly and the query criteria is being passed this way?????
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top