|
-
Jan 30th, 2004, 03:17 PM
#1
Thread Starter
New Member
Excel Distiller VBA
I would like some help with my vb code. I have been trying to convert my .PS file to .PDF without success. I do create the .PS file, however i cannot automatically convert it to .PDF. Here is my code:
Dim PSFileName As String, PDFFileName As String, DistillerCall As String
Dim ReturnValue As Variant
'Define the path and filenames (can get the names from a cell, and add the path & extension):
PSFileName = "c:\excel\target.ps"
PDFFileName = "c:\excel\target.pdf"
'If the files already exist, delete them:
If Dir(PSFileName) <> "" Then Kill (PSFileName)
If Dir(PDFFileName) <> "" Then Kill (PDFFileName)
'The Sendkeys characters are the full path and filename, followed by the "Enter" key.
' These are buffered until the "print to file" screen appears:
SendKeys PSFileName & "{ENTER}", False
ActiveSheet.PrintOut , PrintToFile:=True
'Add double quotes around the PS filename and PDF filename:
PSFileName = Chr(34) & PSFileName & Chr(34)
PDFFileName = Chr(34) & PDFFileName & Chr(34)
DistillerCall = "C:\Program Files\Adobe\Acrobat
6.0\Distillr\Acrodist.exe" &
" /n /q /o" & PDFFileName & " " & PSFileName
'Call the Acrobat Distiller to distill the PS file. ReturnValue is zero
'if the application doesn't open correctly:
ReturnValue = Shell(DistillerCall, vbNormalFocus)
if ReturnValue = 0 Then MsgBox "Creation of " & PDFFilename & "failed."
When i get to the line at the bottom that says:" ReturnValue " i get an error that says file not found and the process stops. The ps file is still there but i does not convert into pdf.
If anyone has another solution for automating .PS to PDF i would greatly appreciate it.
Andre
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|