Save to....

D

David

Since my knowledge of VBA is limited, I have recorded the
following macro to print my document as a .prn file in a
certain location using a certian printer driver, then
return the active printer to the default printer:

ActivePrinter = "APS-PS PIP with APS-6-108 v49.3 or 52.2"
Application.PrintOut FileName:="",
range:=wdPrintAllDocument, Item:= _
wdPrintDocumentContent, Copies:=1, Pages:="",
PageType:=wdPrintAllPages, _
Collate:=True, Background:=True,
PrintToFile:=True, PrintZoomColumn:=0, _
PrintZoomRow:=0, PrintZoomPaperWidth:=0,
PrintZoomPaperHeight:=0, _
OutputFileName:="C:\My PDFs", Append:=False
ActivePrinter = "\\TCG_SERVER\CNC_4050"
With Dialogs(wdDialogFilePrint)
.PrintToFile = False
.Execute
End With

I want to change the 'OutputFileName:="C:\My PDFs",' so
that it takes the name of the original document and names
it 'OriginalDocumentName.prn'. How is that coded?

I also included the last 4 lines of code to uncheck
the 'Print to file' check box the next time the Print
dialog is accessed, however it unchecks the box but also
prints the document, which I don't want. I tried .Update,
but that didn't work. Any suggestions?

TIA
David
 
W

Word Heretic

G'day "David" <[email protected]>,

append it to the name like so:

OutputFileName:="C:\My PDFs\" & activedocument.name

Steve Hudson
Word Heretic Sydney Australia
Tricky stuff with Word or words

Email: WordHeretic at tpg.com.au


David was spinning this yarn:
 
D

David

Thanks for the help!

Any suggestions to the second half of my question,
regarding the 'Print to file' checkbox?

Thanks
David
 
W

Word Heretic

G'day "David" <[email protected]>,

remove the .execute

Steve Hudson
Word Heretic Sydney Australia
Tricky stuff with Word or words

Email: WordHeretic at tpg.com.au


David was spinning this yarn:
 
D

David

Thanks for the response, Steve.

If I remove the .Execute, the checkbox is still checked
when I open the FilePrint dialog box the next time. I've
tried .Update, which didn't work, but .Execute seems to be
the only way to uncheck it. Your help is appreciated.

Thanks
David

P.S. I've made a slight refinement to your previous
suggestion:

Dim a As String
a = ActiveDocument.Name
a = Left(a, Len(a) - 4) 'Strip .doc file extension


OutputFileName:="C:\My PDFs\" & a & ".prn"
 
W

Word Heretic

G'day "David" <[email protected]>,

Bugger - I suspected that might be the case. Know ye now that most
word dialogs are fundamentally broken from an API perspective - a MS
rush job from forms1.0 to forms2.0.

As for your mod, well done, but I'd just remove the last three and add
prn ;-)

Steve Hudson
Word Heretic Sydney Australia
Tricky stuff with Word or words

Email: WordHeretic at tpg.com.au


David was spinning this yarn:
 

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