Print Control in Word/Excel

  • Thread starter Thread starter Ravi
  • Start date Start date
R

Ravi

Hello

I want to place a 'Button' Control in Excel and Word files.

I want the button to bring up the Print dialogue, just the same way as going
to FILE --> Print would do

How do I do this?

Thank you
 
Sub ShowPrtDlgWord()
Application.Dialogs(wdDialogFilePrint).Show
End Sub

Sub ShowPrtDlgExcel()
Application.Dialogs(xlDialogPrint).Show
End Sub
 
From Excel, create a sheet button and assign it to this macro:
Sub PrintDialog()
Application.Dialogs(xlDialogPrint).Show
End Sub

From Word, use this one:
Sub PrintDialog()

Application.Dialogs(wdDialogFilePrint).Show
End Sub

Or from either application use this routine:
Sub PrintDialog()
If Application.Name = "Microsoft Excel" Then
Application.Dialogs(8).Show
ElseIf Application.Name = "Microsoft Word" Then
Application.Dialogs(88).Show
End If
End Sub
 
Hi Ravi

In Word this is fairly straightforward. I'm assuming you want to put a
button on a toolbar. Go to Tools, Customize. Select All Commands from the
Categories list, and then FilePrint from the Commands list. Drag the command
to the toolbar you want it placed on.

In Excel, the process it similar. Go to Tools, Customize. Select File from
the Categories list, and then "Print..." from the Commands list. Drag the
command to the toolbar you want it placed on.
 
In excel, you can assign your button code like this:

Option Explicit
Sub testme()
Application.Dialogs(xlDialogPrint).Show
End Sub
 
Back
Top