create pdf file from vba

N

Nader

Hello,

I've code right here that create a pdf from any document and merge it to
another existing pdf. My only problem is that when I use the function >>>>>
avFormCapture.Open "", "" <<<<< to create the pdf, the files is opened.

Is there way so nothing open or instead just some kind of progress bar ?

Thanks

The code I use :

Option Compare Database
Option Explicit

Sub Attach2Pdf()

Dim objCurrent As AccessObject
Dim Acroapp As CAcroApp
Dim avCodeFile As CAcroAVDoc
Dim avFormCapture As CAcroAVDoc
Dim pdCodeFile As CAcroPDDoc
Dim pdFormCapture As CAcroPDDoc
Dim lngPage As Long

'Start Acrobat in the background
Set Acroapp = CreateObject("AcroExch.App")

'Uncomment the following line if you want to watch the program run
'Acroapp.Show

Set avCodeFile = CreateObject("AcroExch.AVDoc") 'This is the code file
Set avFormCapture = CreateObject("AcroExch.AVDoc") 'This will be each
jpg in turn

'Open the fax
avCodeFile.Open "C:\Documentation\CodeFile.pdf", "Fax Sent"
Set pdCodeFile = avCodeFile.GetPDDoc

'Open the receipt in order to be merged with the fax
avFormCapture.Open "C:\Documentation\email.doc", "Fax Receipt"
Set pdFormCapture = avFormCapture.GetPDDoc

lngPage = pdCodeFile.GetNumPages - 1

'Insert the file at the right page
pdCodeFile.InsertPages lngPage, pdFormCapture, 0, 1, 0

pdFormCapture.Close
avFormCapture.Close 1
Set pdFormCapture = Nothing

'close the doc file now with form captures
pdCodeFile.Close
avCodeFile.Close 0

'Exit Acrobat
Acroapp.Exit
Set objCurrent = Nothing
Set Acroapp = Nothing
Set avCodeFile = Nothing
Set pdCodeFile = Nothing
Set avFormCapture = Nothing

End Sub
 
N

Nader

sorry I wasn't thinking.
Is there a way to create a pdf using vba from an outlook message ?
thanks.
 
K

Ken Slovak - [MVP - Outlook]

Not unless you have some addin or other code that would create a PDF file,
Outlook has no native support for PDF and neither does VBA.
 

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