{"id":12200,"date":"2014-06-15T07:51:35","date_gmt":"2014-06-15T07:51:35","guid":{"rendered":"http:\/\/www.learnexcelmacro.com\/wp\/?p=3795"},"modified":"2017-07-19T06:15:33","modified_gmt":"2017-07-19T06:15:33","slug":"excel-macro-to-print","status":"publish","type":"post","link":"https:\/\/vmlogger.com\/excel\/2014\/06\/excel-macro-to-print\/","title":{"rendered":"Excel Macro : Excel VBA code to Print the Sheet"},"content":{"rendered":"

Hello Friends,<\/p>\n

Hope you are doing well !! Thought of sharing a small VBA code to help you writing a code to print the Workbook, Worksheet, Cell Range, Chart etc. .PrintOut ()<\/i><\/strong> Method is used to print any Excel Object.<\/p>\n

Syntax of .PrintOut Method<\/h1>\n

YourObj.PrintOut(From, To, Copies, Preview, ActivePrinter, PrintToFile, Collate, PrToFileName, IgnorePrintAreas)<\/i><\/p>\n

Where:<\/h2>\n\n\n\n
\n
    \n
  • YourObj (Required): <\/strong>It is a variable which represents your Object which you want to print. For example: Workbook, Worksheet, Chart etc.<\/li>\n
  • From (Optional): <\/strong>Starting page number from which printing has to start. If this argument is omitted, printing starts from page 1.<\/li>\n
  • To (Optional): <\/strong>End page number till which printing has to be done. If omitted, printing will be done till the last page.<\/li>\n
  • Copies (Optional): <\/strong> This is the number of copies to be printed. If omitted, only one copy will be printed.<\/li>\n
  • Preview (Optional): <\/strong>If passed as TRUE<\/strong> then Excel will invoke the print preview before printing the Object. If omitted, FALSE<\/strong> will be passed and hence excel will invoke the printing directly without showing the preview.<\/li>\n
  • ActivePrinter (Optional): <\/strong> This sets the name of the active printer<\/li>\n
  • PrintToFile (Optional): True<\/strong> is passed to print to a file. If it is not specified then user is prompt to enter an output file.<\/li>\n
  • Collate (Optional): <\/strong> This is a Boolean type argument. TRUE<\/strong> is to collate multiple copies.<\/li>\n
  • PrToFileName (Optional): <\/strong> If the above parameter PrintToFile<\/strong> is set to TRUE then you need to specify the name of the file you want to print to<\/li>\n
  • IgnorePrintAreas (Optional): <\/strong> This is a Boolean type argument. If this argument is set to true then this function print the entire object.<\/li>\n<\/ul>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n

    Examples to Print Excel:<\/h1>\n

    Based on above explanation and Syntax we will see examples of printing the Workbook, sheets, charts etc.<\/p>\n

    Example 1: VBA Statements to Print Objects with Default Options<\/h1>\n

    In this set of examples, I am using all default options to print. This means I am not providing any other parameter to the method .PrintOut<\/strong><\/p>\n

    1. VBA code to print ActiveWorkbook<\/h1>\n
    \r\nFunction PrintActiveWorkbook()\r\n      ActiveWorkbook.PrintOut\r\nEnd Function\r\n\r\n<\/code><\/pre>\n

    2. VBA code to print Active Sheet<\/h1>\n
    \r\nFunction PrintActiveSheet()\r\n      ActiveSheet.PrintOut\r\nEnd Function\r\n\r\n<\/code><\/pre>\n

    3. VBA code to print all WorkSheets<\/h1>\n
    \r\nFunction PrintAllWorkSheets()\r\n      WorkSheets.PrintOut\r\nEnd Function\r\n\r\n<\/code><\/pre>\n

    4. VBA code to print a Single Sheet<\/h1>\n
    \r\nFunction PrintOneSheet()\r\n      Sheets("Sheet1").PrintOut 'Sheet1 is the name of the Sheet which you want to Print\r\nEnd Function\r\n\r\n<\/code><\/pre>\n

    5. VBA code to print more than one Sheet<\/h1>\n
    \r\nFunction PrintMultipleSheets()\r\n      Sheets(Array("Sheet1" , "Sheet2", "Sheet3").PrintOut \r\nEnd Function\r\n\r\n<\/code><\/pre>\n

    6. VBA code to print Selected area of a Sheet<\/h1>\n
    \r\nFunction PrintSelectedArea()\r\n      Selection.PrintOut \r\nEnd Function\r\n\r\n<\/code><\/pre>\n

    7. VBA code to print Range of Worksheet<\/h1>\n
    \r\nFunction PrintRange()\r\n      Range("A1:D5").PrintOut \r\nEnd Function\r\n\r\n<\/code><\/pre>\n

    8. VBA code to print Excel Chart<\/h1>\n
    \r\nFunction PrintChart()\r\n      Sheets("Sheet1").ChartObjects("Chart1").Chart.PrintOut 'Chart1 is name of the Chart\r\nEnd Function\r\n\r\n<\/code><\/pre>\n

    9. VBA code to print All Charts in a WorkSheet<\/h1>\n
    \r\nFunction PrintAllChart()\r\nDim ExcelCharts As Object\r\nSet ExcelCharts = Sheets("Sheet1").ChartObjects\r\nFor Each Chart In ExcelCharts\r\n    Chart.Chart.PrintOut\r\nNext\r\nEnd Function\r\n\r\n\r\n<\/code><\/pre>\n

    10. VBA code to print All Charts in a Workbook<\/h1>\n
    \r\nFunction PrintAllChart()\r\n\tDim ExcelCharts As Object\r\n\tFor Each Sheet In Sheets\r\n\t\tSet ExcelCharts = Sheet.ChartObjects\r\n\t\tFor Each Chart In ExcelCharts\r\n\t\t\tChart.Chart.PrintOut\r\n\t\tNext\r\n\t\tSet ExcelCharts = Nothing\r\n\tNext\r\nEnd Function\r\n<\/code><\/pre>\n

    Example 2: VBA Statements to Print Objects with different parameters passed<\/h1>\n

    1. VBA code to print From Page Number X<\/i> to Page Number Y<\/i><\/h2>\n
    \r\n'Below statement will print from Page No:2 to Page No:3\r\nWorksheets("Sheet1").PrintOut From:=2, To:=3\r\n<\/code><\/pre>\n

    2. VBA code to print more than 1 Copy<\/h2>\n
    \r\n'Below statement will print 3 copy of the Sheet1 from Page 2 to Page no: 3\r\nWorksheets("Sheet1").PrintOut From:=2, To:=3, Copies:=3\r\n<\/code><\/pre>\n

    3. VBA code to Show Print Preview before actual printing<\/h2>\n
    \r\n'Below statement will print 3 copy of the Sheet1 from Page 2 to Page no: 3\r\nWorksheets("Sheet1").PrintOut From:=2, To:=3, Copies:=3, Preview:=True\r\n<\/code><\/pre>\n<\/span>","protected":false},"excerpt":{"rendered":"

    Hello Friends, Hope you are doing well !! Thought of sharing a small VBA code to help you writing a code to print the Workbook, Worksheet, Cell Range, Chart etc. .PrintOut () Method is used to print any Excel Object. Syntax of .PrintOut Method YourObj.PrintOut(From, To, Copies, Preview, ActivePrinter, PrintToFile, Collate, PrToFileName, IgnorePrintAreas) Where: YourObj […]<\/p>\n","protected":false},"author":45,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_et_pb_use_builder":"","_et_pb_old_content":"","_et_gb_content_width":"","footnotes":""},"categories":[1246,1675],"tags":[],"class_list":["post-12200","post","type-post","status-publish","format-standard","hentry","category-macro","category-excel-macro-for-beginners"],"yoast_head":"\nAll about printing sheets, workbook, charts etc. from Excel VBA - LearnExcelMacro.com<\/title>\n<meta name=\"description\" content=\"All about printing Excel sheets using Excel VBA. Print your workbook, Worksheet, more than 1 sheet, chart, selected range, limited pages etc. .PrintOut()\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/vmlogger.com\/excel\/2014\/06\/excel-macro-to-print\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Excel Macro : Excel VBA code to Print the Sheet\" \/>\n<meta property=\"og:description\" content=\"All about printing Excel sheets using Excel VBA. Print your workbook, Worksheet, more than 1 sheet, chart, selected range, limited pages etc. .PrintOut()\" \/>\n<meta property=\"og:url\" content=\"https:\/\/vmlogger.com\/excel\/2014\/06\/excel-macro-to-print\/\" \/>\n<meta property=\"og:site_name\" content=\"Let's excel in Excel\" \/>\n<meta property=\"article:publisher\" content=\"http:\/\/www.facebook.com\/vmlogger\" \/>\n<meta property=\"article:author\" content=\"http:\/\/www.facebook.com\/vmlogger\" \/>\n<meta property=\"article:published_time\" content=\"2014-06-15T07:51:35+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2017-07-19T06:15:33+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/vmlogger.com\/excel\/wp-content\/uploads\/sites\/11\/2022\/07\/vmlogger.com_-1.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"628\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Vishwamitra Mishra\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@https:\/\/www.twitter.com\/learnexcelmacro\" \/>\n<meta name=\"twitter:site\" content=\"@learnexcelmacro\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Vishwamitra Mishra\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/vmlogger.com\/excel\/2014\/06\/excel-macro-to-print\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/vmlogger.com\/excel\/2014\/06\/excel-macro-to-print\/\"},\"author\":{\"name\":\"Vishwamitra Mishra\",\"@id\":\"https:\/\/vmlogger.com\/excel\/#\/schema\/person\/7500a107b0b2d35a8492acf0d11fc8e5\"},\"headline\":\"Excel Macro : Excel VBA code to Print the Sheet\",\"datePublished\":\"2014-06-15T07:51:35+00:00\",\"dateModified\":\"2017-07-19T06:15:33+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/vmlogger.com\/excel\/2014\/06\/excel-macro-to-print\/\"},\"wordCount\":442,\"commentCount\":24,\"publisher\":{\"@id\":\"https:\/\/vmlogger.com\/excel\/#\/schema\/person\/7500a107b0b2d35a8492acf0d11fc8e5\"},\"articleSection\":[\"Excel Macro\",\"Excel Macro Tutorial\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/vmlogger.com\/excel\/2014\/06\/excel-macro-to-print\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/vmlogger.com\/excel\/2014\/06\/excel-macro-to-print\/\",\"url\":\"https:\/\/vmlogger.com\/excel\/2014\/06\/excel-macro-to-print\/\",\"name\":\"All about printing sheets, workbook, charts etc. from Excel VBA - LearnExcelMacro.com\",\"isPartOf\":{\"@id\":\"https:\/\/vmlogger.com\/excel\/#website\"},\"datePublished\":\"2014-06-15T07:51:35+00:00\",\"dateModified\":\"2017-07-19T06:15:33+00:00\",\"description\":\"All about printing Excel sheets using Excel VBA. Print your workbook, Worksheet, more than 1 sheet, chart, selected range, limited pages etc. .PrintOut()\",\"breadcrumb\":{\"@id\":\"https:\/\/vmlogger.com\/excel\/2014\/06\/excel-macro-to-print\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/vmlogger.com\/excel\/2014\/06\/excel-macro-to-print\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/vmlogger.com\/excel\/2014\/06\/excel-macro-to-print\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/vmlogger.com\/excel\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Excel Macro\",\"item\":\"https:\/\/vmlogger.com\/excel\/macro\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Excel Macro : Excel VBA code to Print the Sheet\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/vmlogger.com\/excel\/#website\",\"url\":\"https:\/\/vmlogger.com\/excel\/\",\"name\":\"Let's excel in Excel\",\"description\":\"Let's share knowledge\",\"publisher\":{\"@id\":\"https:\/\/vmlogger.com\/excel\/#\/schema\/person\/7500a107b0b2d35a8492acf0d11fc8e5\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/vmlogger.com\/excel\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\/\/vmlogger.com\/excel\/#\/schema\/person\/7500a107b0b2d35a8492acf0d11fc8e5\",\"name\":\"Vishwamitra Mishra\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/vmlogger.com\/excel\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/vmlogger.com\/excel\/wp-content\/uploads\/sites\/11\/2022\/07\/avataaars-1.png\",\"contentUrl\":\"https:\/\/vmlogger.com\/excel\/wp-content\/uploads\/sites\/11\/2022\/07\/avataaars-1.png\",\"width\":528,\"height\":560,\"caption\":\"Vishwamitra Mishra\"},\"logo\":{\"@id\":\"https:\/\/vmlogger.com\/excel\/#\/schema\/person\/image\/\"},\"description\":\"My name is Vishwamitra Mishra. Friends Call me Vishwa. I hold a Bachelor\u2019s Degree in Computer Science from D.A.V.V. Indore & currently working as a Technical Lead having over 7 years of experience.\",\"sameAs\":[\"http:\/\/www.learnexcelmacro.com\",\"http:\/\/www.facebook.com\/vmlogger\",\"https:\/\/x.com\/https:\/\/www.twitter.com\/learnexcelmacro\",\"https:\/\/www.youtube.com\/c\/VMLogger\"],\"url\":\"https:\/\/vmlogger.com\/excel\/author\/vishwamitra\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"All about printing sheets, workbook, charts etc. from Excel VBA - LearnExcelMacro.com","description":"All about printing Excel sheets using Excel VBA. Print your workbook, Worksheet, more than 1 sheet, chart, selected range, limited pages etc. .PrintOut()","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/vmlogger.com\/excel\/2014\/06\/excel-macro-to-print\/","og_locale":"en_US","og_type":"article","og_title":"Excel Macro : Excel VBA code to Print the Sheet","og_description":"All about printing Excel sheets using Excel VBA. Print your workbook, Worksheet, more than 1 sheet, chart, selected range, limited pages etc. .PrintOut()","og_url":"https:\/\/vmlogger.com\/excel\/2014\/06\/excel-macro-to-print\/","og_site_name":"Let's excel in Excel","article_publisher":"http:\/\/www.facebook.com\/vmlogger","article_author":"http:\/\/www.facebook.com\/vmlogger","article_published_time":"2014-06-15T07:51:35+00:00","article_modified_time":"2017-07-19T06:15:33+00:00","og_image":[{"width":1200,"height":628,"url":"https:\/\/vmlogger.com\/excel\/wp-content\/uploads\/sites\/11\/2022\/07\/vmlogger.com_-1.png","type":"image\/png"}],"author":"Vishwamitra Mishra","twitter_card":"summary_large_image","twitter_creator":"@https:\/\/www.twitter.com\/learnexcelmacro","twitter_site":"@learnexcelmacro","twitter_misc":{"Written by":"Vishwamitra Mishra","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/vmlogger.com\/excel\/2014\/06\/excel-macro-to-print\/#article","isPartOf":{"@id":"https:\/\/vmlogger.com\/excel\/2014\/06\/excel-macro-to-print\/"},"author":{"name":"Vishwamitra Mishra","@id":"https:\/\/vmlogger.com\/excel\/#\/schema\/person\/7500a107b0b2d35a8492acf0d11fc8e5"},"headline":"Excel Macro : Excel VBA code to Print the Sheet","datePublished":"2014-06-15T07:51:35+00:00","dateModified":"2017-07-19T06:15:33+00:00","mainEntityOfPage":{"@id":"https:\/\/vmlogger.com\/excel\/2014\/06\/excel-macro-to-print\/"},"wordCount":442,"commentCount":24,"publisher":{"@id":"https:\/\/vmlogger.com\/excel\/#\/schema\/person\/7500a107b0b2d35a8492acf0d11fc8e5"},"articleSection":["Excel Macro","Excel Macro Tutorial"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/vmlogger.com\/excel\/2014\/06\/excel-macro-to-print\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/vmlogger.com\/excel\/2014\/06\/excel-macro-to-print\/","url":"https:\/\/vmlogger.com\/excel\/2014\/06\/excel-macro-to-print\/","name":"All about printing sheets, workbook, charts etc. from Excel VBA - LearnExcelMacro.com","isPartOf":{"@id":"https:\/\/vmlogger.com\/excel\/#website"},"datePublished":"2014-06-15T07:51:35+00:00","dateModified":"2017-07-19T06:15:33+00:00","description":"All about printing Excel sheets using Excel VBA. Print your workbook, Worksheet, more than 1 sheet, chart, selected range, limited pages etc. .PrintOut()","breadcrumb":{"@id":"https:\/\/vmlogger.com\/excel\/2014\/06\/excel-macro-to-print\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/vmlogger.com\/excel\/2014\/06\/excel-macro-to-print\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/vmlogger.com\/excel\/2014\/06\/excel-macro-to-print\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/vmlogger.com\/excel\/"},{"@type":"ListItem","position":2,"name":"Excel Macro","item":"https:\/\/vmlogger.com\/excel\/macro\/"},{"@type":"ListItem","position":3,"name":"Excel Macro : Excel VBA code to Print the Sheet"}]},{"@type":"WebSite","@id":"https:\/\/vmlogger.com\/excel\/#website","url":"https:\/\/vmlogger.com\/excel\/","name":"Let's excel in Excel","description":"Let's share knowledge","publisher":{"@id":"https:\/\/vmlogger.com\/excel\/#\/schema\/person\/7500a107b0b2d35a8492acf0d11fc8e5"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/vmlogger.com\/excel\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/vmlogger.com\/excel\/#\/schema\/person\/7500a107b0b2d35a8492acf0d11fc8e5","name":"Vishwamitra Mishra","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/vmlogger.com\/excel\/#\/schema\/person\/image\/","url":"https:\/\/vmlogger.com\/excel\/wp-content\/uploads\/sites\/11\/2022\/07\/avataaars-1.png","contentUrl":"https:\/\/vmlogger.com\/excel\/wp-content\/uploads\/sites\/11\/2022\/07\/avataaars-1.png","width":528,"height":560,"caption":"Vishwamitra Mishra"},"logo":{"@id":"https:\/\/vmlogger.com\/excel\/#\/schema\/person\/image\/"},"description":"My name is Vishwamitra Mishra. Friends Call me Vishwa. I hold a Bachelor\u2019s Degree in Computer Science from D.A.V.V. Indore & currently working as a Technical Lead having over 7 years of experience.","sameAs":["http:\/\/www.learnexcelmacro.com","http:\/\/www.facebook.com\/vmlogger","https:\/\/x.com\/https:\/\/www.twitter.com\/learnexcelmacro","https:\/\/www.youtube.com\/c\/VMLogger"],"url":"https:\/\/vmlogger.com\/excel\/author\/vishwamitra\/"}]}},"_links":{"self":[{"href":"https:\/\/vmlogger.com\/excel\/wp-json\/wp\/v2\/posts\/12200"}],"collection":[{"href":"https:\/\/vmlogger.com\/excel\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/vmlogger.com\/excel\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/vmlogger.com\/excel\/wp-json\/wp\/v2\/users\/45"}],"replies":[{"embeddable":true,"href":"https:\/\/vmlogger.com\/excel\/wp-json\/wp\/v2\/comments?post=12200"}],"version-history":[{"count":0,"href":"https:\/\/vmlogger.com\/excel\/wp-json\/wp\/v2\/posts\/12200\/revisions"}],"wp:attachment":[{"href":"https:\/\/vmlogger.com\/excel\/wp-json\/wp\/v2\/media?parent=12200"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/vmlogger.com\/excel\/wp-json\/wp\/v2\/categories?post=12200"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/vmlogger.com\/excel\/wp-json\/wp\/v2\/tags?post=12200"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}