calbs
06-11-2015, 04:39 PM
Hello,
I wanted to post this solution I came up with to solve a problem our business is experiencing in Word 2013 (Office 365) to help others who may be searching for this topic later. This forum frequently shows up in Google searches. Let me know what you think.
Problem: When using wdPrintCurrentPage in Word 2013 VBA, the macro would run and print the first page of the document and not the current page.
The document tested on was several pages long and no matter what page was selected it would print the first page.
Note: We have multiple network printers and part of the code is to define the appropriate printer before printing.
Original Code:
ActivePrinter = "\\network-printer-name"
ActiveDocument.PrintOut Range:=wdPrintCurrentPage
Work around / Solution Code:
Sub PrintPage()
'
' PrintPage Macro
'
'
Dim pagenum As String
pagenum = Selection.Information(wdActiveEndAdjustedPageNumber)
ActivePrinter = "\\network-printer-name"
Application.PrintOut FileName:="", Range:=wdPrintFromTo, From:=pagenum, To:=pagenum
End Sub
I wanted to post this solution I came up with to solve a problem our business is experiencing in Word 2013 (Office 365) to help others who may be searching for this topic later. This forum frequently shows up in Google searches. Let me know what you think.
Problem: When using wdPrintCurrentPage in Word 2013 VBA, the macro would run and print the first page of the document and not the current page.
The document tested on was several pages long and no matter what page was selected it would print the first page.
Note: We have multiple network printers and part of the code is to define the appropriate printer before printing.
Original Code:
ActivePrinter = "\\network-printer-name"
ActiveDocument.PrintOut Range:=wdPrintCurrentPage
Work around / Solution Code:
Sub PrintPage()
'
' PrintPage Macro
'
'
Dim pagenum As String
pagenum = Selection.Information(wdActiveEndAdjustedPageNumber)
ActivePrinter = "\\network-printer-name"
Application.PrintOut FileName:="", Range:=wdPrintFromTo, From:=pagenum, To:=pagenum
End Sub