Print to File Dialog box

D

dvdastor

Currently using MS Word 2007.... Does anyone know how to control the
"Print to File" dialog box that comes up after a user chooses that
option on the File Print dialog?

here is my current code:

Sub CapturePrintFileName()

Dim dlg As Dialog
Set dlg = Dialogs(wdDialogFilePrint)
With dlg
..PrintToFile = 0
If .Display = -1 And .PrintToFile = 1 Then
.Execute
End If
End With

End Sub

This brings up the dialogs as it should, but when the "Print to File"
dialog box comes up, I cannot seem to interact with it. On the "OK"
click of that form, i need to capture the Filename that the user types
in. Can anyone help with this?

Thanks!
 
O

old man

Hi dvdstor,

I don't think it is possible. What is happening is that you can determine if
the user chose to print to a file by checking the printtofile value that is
returned from the fileprint dialog. (See code below.)

When the execute happens Word prompts the user with a file save dialog with
a File Print To caption. What you may want to do is if the user chose to
print to a file instead of doing the .execute show your own dialog to save as
and then do a print to a file through code.

Old Man

Sub ShowPrintDlg()

With Dialogs(wdDialogFilePrint)
.Display
MsgBox " printtofile " & .printtofile
.Execute
End With

End Sub
 

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