From xls to ps

R

Riccardo

Hy all,
i do a macro under ms word connet to a button that save a word file
to a ps with a "Default PostScript Printer"

Now i must do this under excel but i don't find an example that help
me.
I find this vba code:
Private Sub CommandButton1_Click()


' Define the postscript and .pdf file names.
Dim PSFileName as String
Dim PDFFileName as String
PSFileName = "c:\myPostScript.ps"
PDFFileName = "c:\myPDF.pdf"


' Print the Excel range to the postscript file
Dim MySheet As WorkSheet
Set MySheet = ActiveSheet
MySheet.Range("myRange").PrintOut copies:=1, preview:=False,
ActivePrinter:="Acrobat Distiller", printtofile:=True, collate:=True,
prttofilename:=PSFileName


' Convert the postscript file to .pdf
Dim myPDF As PdfDistiller
Set myPDF = New PdfDistiller
myPDF.FileToPDF PSFileName, PDFFileName, ""


End Sub

but it return an error with prttofilename:=PSFileName

Anyone have a valid source?

Tnx a lot
Bye
Riccardo
 
F

Frank Kabel

Hi Riccardo
one idea from seeing you example:
the line
prttofilename:=PSFileName

belongs to the line above so try
ActivePrinter:="Acrobat Distiller", printtofile:=True, collate:=True,
prttofilename:=PSFileName
as ONE line (there may be a line break from your newsreader)
You may also have to reference the Adobe library for creating a new
PDFDistiller object

Frank
 
R

Riccardo

Hi Frank
the problem is prttofilename:=PSFileName, infact if i remove it, i
don't have the error.

The best solution that i search is with a general PS printer (Ex.
Default PostScript Printer)

I do it with a macro under ms word but under excel it seem
impossibile...

Thx
Riccardo
 
F

Frank Kabel

Hi Ricardo
try appending the part
prttofilename:=PSFileName

to the line above. This may work
 
R

Riccardo

Hy,
the command is in one line but i have the error. I think that the
problem is the version of office (Office 97).

Any ideas?
Tnx
Riccardo
 
F

Frank Kabel

Hi
what error did you get. You may have to reference the PDF library in
the VBA editor
 
R

Riccardo

The Error is (italian: Impossibile trovare argomento predefinito)
unable to find predefinite argument

and it highlights prttofilename:=PSFileName

In the Excel help for the function PrintOut there is
espressione.PrintOut(From, To, Copies, Preview, ActivePrinter, PrintToFile, Collate)
so there isn't the value of the file name

Bye
Riccardo
 
F

Frank Kabel

Hi
try replacing PSFileName with a name of your choice. This will be the
filename to which you save your PDF file. Or better add a line before
the Printout command:
PSFileName = "C:\temp\test.pdf" 'change to your needs
 
R

Riccardo

The same erros, i'm thinking that the problem is the version of excel.

Other ideas?

Bye
Riccardo
 
D

Dave Peterson

I don't see the beginning of this thread, but the prttofilename stuff was added
in xl2k.

Are you running xl97?
 
R

Riccardo

Yes xl 97, infact yesterday i tried it on xls 2003 and it work but i
must do it under xl 97

Other ideas? External program controlled by a macro?

Bye
Riccardo
 

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