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!

Exporting a Report to MS Word in Document Format instead of RTF 3

Status
Not open for further replies.

JPeters

MIS
Jul 25, 2001
423
US
Fellow Access Guru's,
Once again my best friend Microsoft has managed to hurt my head. Hopefully this won't hurt you guys as much as it has me. The question is relatively simple.
I've got a form that I've made. This form has boxes/pictures and other fancy things... however, when I export the report to MS Word, it immediately saves it as a RTF file and then all my pretty stuff is lost!!! I'm stuck with text only.
Now, when I export a FORM (form, not report) to MS Word, I keep all of my lovely boxes and pictures because it just throws the file into word without saving it to an RTF file first. Why is that?
How can I make it so I keep my beautiful report design when I send it to MS Word via the export to MS Word box/command. Thanks a ton folks.

-Happen609
Wasting more of your valuable time...
 
Unfortunately, I don't think there's a work around for this. When you export your report, it's pretty much the same thing as saving to an HTML page. You lose a lot in the process.

Have you tried saving as a snapshot (*.snp) instead ?? the viewer is free at Microsofts; web site, and it is EXACTLY like your report....

Otherwise, you CAN do it prgramatically, by creating a word object from within access and controlling/setting the document properties. But that is a bit of work.
 
DB Guy,
Great advice.... I've got time and Lord knows I love work. Lay it on me, how do I do it?

-Happen609
 
Here's a simple version. Create a word document and save it as a template. Place one bookmark in it called Access. Note, when your in the module, go to tools/references and check Microsoft Word 8.0(9.0 whatever you have) object library.

Also, make sure your SQL statement only returns one record for this example.

Now start a new module and paste this code.

Private Sub ExportOneRecordtoWord()
Dim objWord As Object
Dim DBS As Database
Dim RST As Recordset
Dim strSQL As String
Set objWord = New Word.Application
Set DBS = CurrentDb
strSQL = "SELECT SomeField from SomeTabel"
Set rst = openrecordset(strSQL) _
objWord.Documents.OpenFileName:="File&Path Here.doc"
objWord.Visible = True
With objWord.ActiveDocument.Bookmarks
.Item("Access").Range.Text = " " & rst.fields _
(name or index).value
End With
Set objWord = Nothing
Set DBS = Nothing
Set RST = Nothing
End Sub

There, we've just grabbed one record out of access & put it into a word document. Like I said, a lot of work.

Now, hit F2 while you're in the VBE and start browsing the word objects. You'll probably need to use tables. Also, if your report is grouped at any levels, you'll need several nested for..while..loops in your code.

I've got a sample I could E-mail you.

 
DB Guy,
Wow, how did you learn all of this stuff. Heck yes I'd love the sample!

-Happen609
 
DB Guy,
Whoops, here's the e-mail

jpeters@guidemail.com

Thanks

-Happen609
 
Would it also be possible to email me a sample of what you have done

holdsworthmatthew@hotmail.com
 
Hi DataBaseGuy

I was searching posts for my Access Report to Word problem when I came across your posts. Would I also be able to get a copy of your sample?

My e-mail is hims.sperritt@sympatico.ca

Thanks very much!!

MoJoP
 
I would love to get a copy of this sample if someone could email it to me also, please.

Thanks in advance,

lorii@ccs.k12.nc.us
 
I, too, would very much appreciate a copy.
Email: mpetzold@mclindustriesinc.com
Thanks in advance!
 
I've just stumbled across this thread & thought I'd throw my 2ps worth in.
I have an example on my site called Quiz.mdb that does a similar thing to DatabaseGuy's but outputs it as HTML to be displayed on the web.

An alternate way to produce an almost exact copy of your report in word, without building a template can be found at
This has a library database that you can just link to your applicaiton & produce word reports till you're sick!


HTH

Ben ----------------------------------------
Ben O'Hara
----------------------------------------
 
I too would like to see your code to export a report (with lines) to a Word document.

Thanks
rich.craven@rotometrics.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top