Sending Report to Word - Lebans solution

J

John Dumay

Hi All,

i am trying to cusomise use Stephan Lebans utility that allow me to roint my
report into a Word document (EMF Picture Objects). I have made a refence to
his .MDE database and recomplied the utility to make sure this all works. But
hen I copy the code behind the "Export to File" button to my Database I get
complie errors. First if I leave the following declaration in my from module

Dim pf As clsPrintToFit

I get this Error when compiling.

"User-defined type not defined"

I avoided this Error my declaring as public in my manin DB module but i am
not sure of this is the right thing to do.

Public pf As clsPrintToFit

Next, the complier stops at the call to the export comand;

pf.ExportToMSWord

Here the compiler highlights "pf" and says:


"Variable not defined"

Has any one got this code to work in their DB's and can offer help I would
greatly appreciate it.

Regards,

John Dumay
 
J

John Dumay

Doug,

Thanks for pointing me in the right direction. I assumed I didn't have to
copy any of these if I referencd the .MDE database. Also I missed 'Set pf =
New clsPrintToFit" on the FormLoad() event. Everything works now except that
all the lines in my report are missing as well as some Text Boxes which are
the title of the report.

Regards,

John Dumay
 
J

John Dumay

Hi Stephen,

Looks like I missed reading that part. Sorry. I hav implemented the Report
to PDF solution and it works just fine.

Thanks for your help.

Regards,

John Dumay
 
D

Dave Ganesh

I have a form which I would like to email right away keeping the same format
as shown in MS Access databse. Currently, I print and save as PDF file using
PDF Creator installed on my PC. Then I email the form to the Customer.

I wanted to place a button on the Form which I can click and using a macro
for instance, I can Email the form as a PDF right away. The Macro in the
database currently only has SendObject as .txt or xls. formats which converts
the form to a different view all together.

How do I get this button to email instantly to the recipient in the pdf
format from the Form in Access database?? Any siggusetions, please note that
I am not an expert at MS Access and VB codes.

Thanks.
 
D

Dave Ganesh

Arvin:

What you said sound like it will work but I am not good at codes at all.
Please correct me if I am wrong:

1. I create a Command button on my form and open properties for Code Builder.
2. I copy and paste everything in your datastrat.com into the Code builder
from Private Sub to End Sub.
3. Here is where you lost me...

Given that the name of the Form is Supplier Scorecard and I have MS Outlook
2003, what exactly do I change next???

Providing I get an answer to make this work, will your code allow me to send
that form as shown on screen (pdf format) on click??

Thanks for the help.......
 
A

Arvin Meyer [MVP]

So let's step through it. Change the name to your command button's name,
then:

Private Sub Command0_Click()
'Arvin Meyer 03/12/1999
'Updated 7/21/2001
On Error GoTo Error_Handler

Dim objOutlook As Outlook.Application
Dim objEmail As Outlook.MailItem

Set objOutlook = CreateObject("Outlook.application")
Set objEmail = objOutlook.CreateItem(olMailItem)

With objEmail
' .To = (e-mail address removed) ' Change this to
. To = Me.txtEmail 'txtEmail is the email textbox on your form
.Subject = "Subject text"
.body = "Body text"
.Attachments.Add "C:\Path to PDF file that has been saved"
'.attachments.Add "c:\Path\to\the\next\file.txt"
.Send
'.ReadReceiptRequested
End With

Exit_Here:
Set objOutlook = Nothing
Exit Sub

Error_Handler:
MsgBox Err & ": " & Err.Description
Resume Exit_Here

End Sub

Now open Tools >>> References and find and check the Outlook reference
Save and compile tour code.
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com
 
D

Dave Ganesh

O.k. I pasted the new code and added Outlook. I got an error because I did
not know what the txtEmail is on my form. Is this the email address of the
recipient? What info exactly do I have to change in your new code besides the
button name?

If I ineterpret your code reasoning correct, are you assuming that I have
already saved the document in a folder as a PDF? Why does it ask for an
attachment path if I am emailing direct from MS Access?

Please let me know, as you can tell, I am not so bright at MS Access codes.
 
A

Arvin Meyer [MVP]

Dave Ganesh said:
O.k. I pasted the new code and added Outlook. I got an error because I did
not know what the txtEmail is on my form. Is this the email address of the
recipient? What info exactly do I have to change in your new code besides
the
button name?


txtEmail is the name of the textbox holding the email address on your form

You also need to change the path to the path to your pdf. You can also save
just the file name and code the line something like:

..Attachments.Add "C:\Foldername\Path\" & Me.txtFilename

so the path will be hard coded and the filename will come from a textbox
named txtFilename on your form.
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com
 

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