macro to print form to PDFCreator

R

Robin

We have a cost of quality database with 18,000 records and growing.
Customer service opens the claim form and finds the claim that they
are looking for. They need to be able to e-mail this to our credit
manager in pdf format so that she can issue the credit memo and so it
can be sent to our imaging software in pdf format. We have PDFCreator
installed on their PC but I want to create a button on the form to
automate this so that they don't accidentally print all 18,000 records
to a pdf file and they don't forget to change their printer to
PDFCreator. I think it will have to be accomplished with VBA code but
I can't figure out how to do this. Any ideas?
 
A

Albert D. Kallal

I would suggest that you use Stephens PDF solution.

The advantage of this solution is that you don't have to install a printer
driver, you don't have to install PDF software, and furthermore you don't
even have to switch printers when you wish to create a PDF a file. And of
course which is really nice it is perfectly 100% free for you to use.

Furthermore, since you're creating a PDF document, then you can't use the
built in command "sendobject". You'll have to resort to using outlook
automaton.

You'll find the code to create the pdf here:

http://www.lebans.com/reporttopdf.htm

You likely should get the above sample working on your computer before you
attempt to move and copy that above code into your own application. (So get
his sample working first). Do note the above sample also requires that you
place the appropriate DLL files in the same folder as your application.

You will have to use outlook automation (and therefore this means the user
will have to be using a outlook, not outlook express for their e-mail
client).

So the whole approach here is that you're going to create a PDF a file that
is SAVED to disk. You then created the e-mail, and then set that pdf file as
an attachment.

The following code shows you how to start an outlook session, and then
attach a file of your choice to the e-mail.

So, *after* you create the pdf file, YOU then simply start a outlook
session, and attach the file you made using the pdf library.

eg:
dim strDocName as string
' send to user via email
'Dim ol As Outlook.Application
Dim ol As Object ' Late binding
'Dim ns As NameSpace
Dim ns As Object ' Late bind
'Dim newmessage As MailItem
Dim newmessage As Object ' Late bind

Dim mymessage As String
'Dim objOutlookAttach As Outlook.Attachment
'Dim objOutlookAttach As Object

strDocname = "c:\mydata\Report.pdf"

Set ol = GetObject(, "Outlook.Application")
Set ns = ol.GetNamespace("MAPI")
ns.Logon
Set newmessage = ol.CreateItem(0) ' 0 = olMainItem
With newmessage
.Recipients.Add strEmailTo
.Subject = strSubject
.Body = strMsgText
'Set objOutlookAttach = .Attachments.Add(stDocName)
.Attachments.Add (strDocName)
.Display
' .Send
End With
 

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