Print to PDF

A

akyhne

ActiveDocument.PrintOut Filename:="test.pdf"

renames original Word filename to the new pdf printname when printing, but

Ny = "test.pdf"
ActiveDocument.PrintOut Filename:=Ny

does nok work!

It gives me an error 5121!
 
D

Doug Robbins - Word MVP

Declare Ny as a String

Dim Ny As String

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
A

akyhne

It is declared.

"Doug Robbins - Word MVP" skrev:
Declare Ny as a String

Dim Ny As String

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
D

Doug Robbins - Word MVP

On checking into causes for a 5121 error, I suspect that the problem maybe
that test.pdf already exists. So, try

Ny = "test.pdf"
Kill Ny
ActiveDocument.PrintOut Filename:=Ny


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
A

akyhne

No, it doesn't. My string waries out of some data in the document.


"Doug Robbins - Word MVP" skrev:
 
A

akyhne

I solved this way:

Y.ActiveDocument.SaveAs Filename:=Vaerdier(2) & "-" & VBA.Format(strDate,
"yyMMdd")
Y.PrintOut

So I simply renamed the file. The Word doc. itselves, is not saved this way.
but printout seems to think that this is the new name.

"Doug Robbins - Word MVP" skrev:
 

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