Macro - dialog box

M

MIrving

Is there a standard macro/code I can use (or modify) for entering a filename
in the dialog box that appears when either saving as/printing?

I tried using the 'Record new macro' and stepped through the steps.
However, it didn't seem to recognise the step when I clicked in the dialog
box to type the filename. When I go to visual basic editor to view the
macro, there is nothing that reflects a step of clicking in the dialog box
and putting in the filename.

Thank you for any suggestions.
 
G

Graham Mayor

The filename would be taken from the document property Title. You can write
to that property, and use that as the filename, eg

Dim sTitle As String
ActiveDocument.BuiltInDocumentProperties(wdPropertyTitle).Value = "Filename"
sTitle = ActiveDocument.BuiltInDocumentProperties(wdPropertyTitle)
ActiveDocument.SaveAs FileName:=sTitle

but if you know the filename you want to use why call the dialog at all.

ActiveDocument.SaveAs FileName:="Filename"

The print dialog does not recall the file name.

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
M

MIrving

Thank you for your suggestions. The macro I want to set up is to enable a
user to click a toolbar button to print the Word document to PDF995. When I
go to File > Print and select PDF995 as the printer, a separate dialog box
then appears which is 'PDF995 save as'. It is in that dialog box that I
would like the filename to be inserted automatically. The filename is to be
taken from a bookmark in the word document. The bookmark will vary depending
on what client name the user inserts.

Thank you for any further suggestions you can offer as to how I can achieve
this (if it is possible) or a code that does anything similiar that I could
play around with to suit.
 
G

Graham Mayor

I have not previously used PDF995 , but the free PDF creation tools are not
usually programmable from within Word and usually require some user
intervention. To achieve this you would probably have to upgrade to Acrobat,
but by all means check with the writers of PDF995. However having checked
with the free version, it picks up the filename pf the document
automatically, and appears to retain the last destination folder for the
files. Thus the following should work

Sub PrintPDF()
Dim sPrinter As String
sPrinter = ActivePrinter
ActivePrinter = "PDF995"
Application.PrintOut
ActivePrinter = sPrinter
End Sub

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 

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