Excel PrintOut using VBA (Visual Basic for Applications) Example

Excel PrintOut using VBA (Visual Basic for Applications) Example


Method prints specific range, print area, sheet or entire Excel workbook based on expression attached to PrintOut method. Let’s put some VBA code to examine various ways to Print.

Print Area

Set a Print Area and give name to it by default Excel adds print area name as “PrintArea“. A sheet can have only one Print Area which can be verified under Name Manager.

Code example

Public Function PrintPrintAreaExample(oPrintAreaName As String) As Boolean
    PrintPrintAreaExample = False
    PrintPrintAreaExample = True
End Function

Print Sheet

Public Function PrintSheetExample(oSheetName As String) As Boolean
    PrintSheetExample = False
    PrintSheetExample = True
End Function

Print Range

Public Function PrintRangeExample(oPrintRange As Range) As Boolean
    PrintRangeExample = False
    PrintRangeExample = True
End Function

Print Workbook

Public Function PrintWorkbookExample(oWorkbook As Workbook) As Boolean
    PrintWorkbookExample = False
    PrintWorkbookExample = True
End Function

Please leave your comments or queries under comment section also please do subscribe to our blogs to keep your self upto date.

Leave a Reply

Your email address will not be published. Required fields are marked *