Please Help With Code

G

Guest

I am sending a report to an RTF file and then using the "mailenvelope.item"
in WORD to place the formatted report in the message body of an email so it
can be easily read on a Blackberry.

I use the following line:

Set wdApp = New Word.Application
wdApp.Visible = True

Set doc = wdApp.Documents.Open("C:\Reports\Report.rtf")

Which opens the document in WORD.

The problem is (I Believe) that the document does not have focus.



Can someone resolve this for me?

Thank you.
 
G

Guest

I finally got the code corrected, the main problem I think was the line:
wdApp.Run

But to share, the following is a click event in an access database which
exports a report in RTF format and send the formatted output as the message
body of an email using the Macro whose code is at the bottom, which needs to
be built into your WORD application. I have been told by the Blackberry
users that attachments are difficult to read compared with the report text
formatted in the message body.

Private Sub Command5_Click()
DoCmd.OutputTo acOutputReport, "NameOfAccessReport", acFormatRTF,
"FullNameAndPathOfOutputFile"

Dim wdApp As Word.Application
Dim doc As Word.Document

Set wdApp = New Word.Application
Set doc = wdApp.Documents.Open("FullNameAndPathOfOutputFile")
wdApp.Run "NameOfMacro"
wdApp.Quit False
Set doc = Nothing
Set wdApp = Nothing

Kill ("FullNameAndPathOfOutputFile")

End Sub

Sub NameOfMacro()

Set Report = ActiveDocument.MailEnvelope.Item
Report.To = "RecipientEmailAddress"
Report.Subject = "WhatEverYouWant"
Report.Send
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top