A family of Microsoft spreadsheet software with tools for analyzing, charting, and communicating data.
Use following statement in your VBA code -
Application.CommandBars.ExecuteMso ("PrintPreviewAndPrint")
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hi all,
I'm looking for a code that can simulate Ctrl+P. I have tried Dialogs(wdDialogFilePrint).Show but it doesn't have (or I couldn't find after 20mins) the option to include all column in one page.
Therefore I need a code that basically simulates Ctrl+P to the excel.
A family of Microsoft spreadsheet software with tools for analyzing, charting, and communicating data.
Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.
Answer accepted by question author
Use following statement in your VBA code -
Application.CommandBars.ExecuteMso ("PrintPreviewAndPrint")
Hey, any idea what is the command to send the user under "Save As"?
Hi Vijay, that was exactly what I needed, thanks!
Hi Benedict,
I'm looking for a code that can simulate Ctrl+P. I have tried Dialogs(wdDialogFilePrint).Show but it doesn't have (or I couldn't find after 20mins) the option to include all column in one page.
Therefore I need a code that basically simulates Ctrl+P to the excel.
Try something like:
'==========>>
Option Explicit
'--------->>
Public Sub Tester()
With ActiveSheet
With .PageSetup
.Zoom = False
.FitToPagesWide = 1
.FitToPagesTall = 10
End With
'\ to preview:
.PrintPreview
'\ or, to print, remove initial apostrophe on next line
'.printout
End With
End Sub
'<<=========
===
Regards,
Norman