A family of Microsoft word processing software products for creating web, email, and print documents.
Try going to File>Options>Advanced and in the Print section, uncheck the box for "Print in background".
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
For a non-duplex printer I want to write a Word macro that prints out the first half of the pages, sends a message box telling me to turn over the paper, and then prints the second half. (The options the Print dialog box offers don’t get the pages in the order I want.) Should be simple enough: calculate the page number, print the first half, wait till the message box is clicked and then print the second half. What actually happens is that the message box appears immediately and nothing is printed until I click it. Then the whole lot gets printed without stopping. Inputbox does the same. Obviously there are workarounds like having 2 separate macros, but I wonder whether there is a way of telling VBA to do the first printing but wait till I’ve clicked the message box before doing the second printing.
A family of Microsoft word processing software products for creating web, email, and print documents.
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.
Try going to File>Options>Advanced and in the Print section, uncheck the box for "Print in background".
Oh thanks, I didn't think of that.
Unfortunately this prints the whole thing, leaving the Msgbox on screen
Thank you.
My version of Word doesn't recognise either Wait or Sleep, and I can't find either listed in the online documentation, except for Excel.
Thanks also for drawing my attention to the Stackoverflow page, but it doesn’t offer a solution.
Hello
I’m Adeyemi and I’d be happy to help you with your question.
It seems like you're experiencing an issue where the MsgBox appears before the first half of the pages are printed. This could be due to the fact that the PrintOut method is asynchronous, meaning it returns immediately after it's called, without waiting for the printing to finish.
One workaround could be to add a delay after the first PrintOut call and before the MsgBox call. This can be done using the Application.Wait method or the Sleep function from the Windows API. Here's an example:
Sub PrintDuplex()
Dim halfway As Integer
halfway = ActiveDocument.ComputeStatistics(wdStatisticPages) \ 2
' Print first half of document
ActiveDocument.PrintOut Range:=wdPrintFromTo, From:="1", To:=CStr(halfway)
' Wait for printing to finish
Application.Wait (Now + TimeValue("00:01:00")) ' waits for 1 minute
' Display message box
MsgBox "Please turn over the paper", vbOKOnly, "Print Duplex"
' Print second half of document
ActiveDocument.PrintOut Range:=wdPrintFromTo, From:=CStr(halfway + 1), To:=""
End Sub
In this code, the Application.Wait method is used to pause the macro for 1 minute before displaying the MsgBox. You might need to adjust the wait time depending on how long it takes for your printer to print the first half of the document. https://stackoverflow.com/questions/44052516/how-to-select-print-on-both-sides-in-ms-word-2013-vba Note: This is a non-Microsoft website. The page appears to be providing accurate, safe information. Watch out for ads on the site that may advertise products frequently classified as a PUP (Potentially Unwanted Products). Thoroughly research any product advertised on the site before you decide to download and install it.'
Please note that this is a simple workaround and might not work perfectly for all printers or documents.
I hope this helps.
Give back to the community. Help the next person who has this issue by indicating if this reply solved your problem. Click Yes or No below.
Kind regards, Adeyemi