Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 06-28-2024, 12:28 PM
rferrin34 rferrin34 is offline Word VBA, Prints multiple copies Windows 11 Word VBA, Prints multiple copies Office 2021
Novice
Word VBA, Prints multiple copies
 
Join Date: Jun 2024
Posts: 2
rferrin34 is on a distinguished road
Default Word VBA, Prints multiple copies

New to the use of VBA and Macro's in word documents.

I am trying to create a macro button\maco, that when clicked will print certain sections of a word document. I have it *almost* working, but with a slight hiccup.

When I run the macro, it prints 3 copies of the document. 2, of the whole document, and the 3rd copy is the range I am looking for.

Here is the code I have so far. Am I missing something?

Sub Fileprint()
ActiveDocument.ActiveWindow.PrintOut Dialogs(wdDialogFilePrint).Show
With Application.ActiveDocument


ActiveDocument.ActiveWindow.PrintOut _
Range:=wdPrintFromTo, From:="2", To:="3"

End With
End Sub

Any help is appreciated!
Reply With Quote
  #2  
Old 06-28-2024, 03:45 PM
Italophile Italophile is offline Word VBA, Prints multiple copies Windows 11 Word VBA, Prints multiple copies Office 2021
Expert
 
Join Date: Mar 2022
Posts: 542
Italophile is just really niceItalophile is just really niceItalophile is just really niceItalophile is just really nice
Default

Your code first calls
Quote:
Originally Posted by rferrin34 View Post
ActiveDocument.ActiveWindow.PrintOut
which prints a full copy of the document. Then it calls

Quote:
Originally Posted by rferrin34 View Post
Dialogs(wdDialogFilePrint).Show
which prints a second copy. Finally it calls the only part you actually need
Quote:
Originally Posted by rferrin34 View Post
Sub Fileprint
ActiveDocument.ActiveWindow.PrintOut _
Range:=wdPrintFromTo, From:="2", To:="3"
End Sub
Reply With Quote
  #3  
Old 06-28-2024, 05:41 PM
rferrin34 rferrin34 is offline Word VBA, Prints multiple copies Windows 11 Word VBA, Prints multiple copies Office 2021
Novice
Word VBA, Prints multiple copies
 
Join Date: Jun 2024
Posts: 2
rferrin34 is on a distinguished road
Default

Ahhh!! Ok!! Now it sort of makes a little more sense! Big thank you!

Hopefully you can help me with the issue that led to the insertion of
"Dialogs(wdDialogFilePrint).Show"

That line seemed to give me what I thought was the "print dialog" box, which allowed me to select the printer I needed. Am I incorrect in thinking that? Without it, the document would only print to whatever my default printer was set at. Is there a way to make that happen?

Quote:
Originally Posted by Italophile View Post
Your code first calls

which prints a full copy of the document. Then it calls


which prints a second copy. Finally it calls the only part you actually need
Reply With Quote
  #4  
Old 06-29-2024, 12:52 AM
Italophile Italophile is offline Word VBA, Prints multiple copies Windows 11 Word VBA, Prints multiple copies Office 2021
Expert
 
Join Date: Mar 2022
Posts: 542
Italophile is just really niceItalophile is just really niceItalophile is just really niceItalophile is just really nice
Default

See Application.ActivePrinter property (Word) | Microsoft Learn

Dialogs have several methods with important differences. See:
Dialog.Display method (Word) | Microsoft Learn
Dialog.Execute method (Word) | Microsoft Learn
Dialog.Show method (Word) | Microsoft Learn
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Printer prints 2 copies. One with macros enabled and other one is disabled. zhansultan Word VBA 0 05-21-2024 03:06 AM
Word VBA, Prints multiple copies Printing multiple copies of docm from Word to PDF saving file with sequential name- 001, 002 etc. SSCMapletart Word VBA 3 04-18-2017 03:04 AM
Create multiple copies of same email in multiple folders gaker10 Outlook 0 10-06-2014 07:44 AM
Word VBA, Prints multiple copies Unable to print multiple copies zip p pong Word 1 03-16-2014 08:56 PM
Merging Multiple Copies of the Same Document bshatto Word 0 10-19-2009 06:22 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 10:34 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft