Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

HOw to control the xlDialogPrint dialog...

65 views
Skip to first unread message

Tim Cornwell

unread,
Jun 7, 1999, 3:00:00 AM6/7/99
to
Thanks again,

I am trying to print/preview the entire workbook from code. I notice that
the
print dialog seems to have the properties I need, but I can't seem to find
what arguments I need to set to get what I want.

Does anyone know where I can find the mappings for the Excel print dialog
arguments? I have something like this:

' >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
With Application.Dialogs(xlDialogPrint)
.Show Arg1:=1, Arg4:=1, Arg5:=False, Arg6:=True, Arg7:=1, Arg8:=5
End With
' >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

...and what I want to do is print preview the entire workbook. I really
don't want the user to see this dialog (if possible), but I would like to
just run the dialog with the parameters I need so the user sees the preview
mode.

I the above example, Arg7 should be (I think) the 'Print What', but it
doesn't seem to map to it.

Thanks In Advance,

Tim Cornwell


Ogilvy, Thomas, W., Mr., ODCSLOG

unread,
Jun 7, 1999, 3:00:00 AM6/7/99
to
the arguments for most of the dialogs are documented in the macrofun.exe
file available from Microsofts support site. The dialog box arguments
echo the arguments for the corresponding Excel 4 macros.

http://support.microsoft.com/support/downloads/LNP129.asp
and download the file Macrofun.exe and xlmacr8.hlp

However, you can do what you want using VBA and not show the a dialog.
Turn on the macro recorder and then go into page Setup and change a
parameter or two. then look at the recorded code. It will show you how
to control the print. You will get output like:

Sub Macro1()

With ActiveSheet.PageSetup
.LeftHeader = ""
.CenterHeader = ""
.RightHeader = ""
.LeftFooter = ""
.CenterFooter = ""
.RightFooter = ""
.LeftMargin = Application.InchesToPoints(0.75)
.RightMargin = Application.InchesToPoints(0.75)
.TopMargin = Application.InchesToPoints(1)
.BottomMargin = Application.InchesToPoints(1)
.HeaderMargin = Application.InchesToPoints(0.5)
.FooterMargin = Application.InchesToPoints(0.5)
.PrintHeadings = False
.PrintGridlines = False
.PrintComments = xlPrintNoComments
.PrintQuality = 600
.CenterHorizontally = False
.CenterVertically = False
.Orientation = xlLandscape
.Draft = False
.PaperSize = xlPaperLetter
.FirstPageNumber = xlAutomatic
.Order = xlDownThenOver
.BlackAndWhite = False
.Zoom = 100
End With
ActiveWindow.SelectedSheets.PrintPreview
End Sub


Only include the settings you need to change - the pagesetup object can
be very slow.


HTH,
Tom Ogilvy

0 new messages