Add Duplex command to Print Button (VBA) - Mr. Excel
文章推薦指數: 80 %
I want pages 1&2, 3&4, 5&6, etc. to print both sides. I have a color printer on the network ... Add Duplex command to Print Button (VBA).
Forums
What'snew
Newposts
ExcelArticles
MrExcelPublishing
Login
Register
What'snew
Search
Newposts
Searchforums
Menu
Login
Register
Installtheapp
Install
Ifyouwouldliketopost,pleasecheckouttheMrExcelMessageBoardFAQandregisterhere.Ifyouforgotyourpassword,youcanresetyourpassword.
Forums
QuestionForums
ExcelQuestions
Youareusinganoutofdatebrowser.Itmaynotdisplaythisorotherwebsitescorrectly.Youshouldupgradeoruseanalternativebrowser.
AddDuplexcommandtoPrintButton(VBA)
Threadstarter
seanjon
Startdate
Jan22,2018
Tags
application.activeprinter
button
print
printer
scurrentprinter
seanjon
NewMember
Joined
Dec23,2017
Messages
10
Goodday.
AworkbookIhavehas22worksheets.Iwantpages1&2,3&4,5&6,etc.toprintbothsides.Ihaveacolorprinteronthenetworkthatisnotmydefaultprinter.Imadeacommandbuttonthatwillsendtheworkbooktothecolorprinter.Ialsowantittoprintitduplex.
ThisiswhatIhaveforthebuttonsofar.Itworksandsendstheworkbooktothatprinter.
Code:
PrivateSubCommandButton1_Click()
DimsCurrentPrinterAsString
ConstMyPrinterAsString="\\vm-print\MARS_BROTHERMFC-9460CDNonNe06:"
sCurrentPrinter=Application.ActivePrinter
Application.ActivePrinter=MyPrinter
ActiveWorkbook.PrintOutFrom:=1,To:=22,Copies:=1,Collate:=True,_
IgnorePrintAreas:=False
Application.ActivePrinter=sCurrentPrinter
EndSub
Throughsearching,Iknowthatthereisacodetosetittoduplex:
Code:
SubSetPrinterToDuplex()
SetPrinterDuplex"\\vm-print\MARS_BROTHERMFC-9460CDNonNe06:",2
EndSub
WhereshouldIputthisinthecodeformycommandbutton,oristheresomethingdifferentIneedtoputinthesub?
Thanksforyourtime.
Sean
ExcelFacts
Differencebetweentwodates
Clickheretorevealanswer
Secretfunction!Use=DATEDIF(A2,B2,"Y")&"years"&=DATEDIF(A2,B2,"YM")&"months"&=DATEDIF(A2,B2,"MD")&"days"
PaulKed
ActiveMember
Joined
Jun4,2015
Messages
442
Youmaybeabletosendcontrolcodestotheprintertotellittoprintinduplexmode,butyouwouldhavetolookthroughtheprinterdocumentationtoseeifthisispossible.
OtherwiseitisprobablypossibleusingthedarkartofAPIcalls,whichIcanonlycopyfromtheWizardsthatwritethem!
PaulKed
ActiveMember
Joined
Jun4,2015
Messages
442
BTW
Code:
SubSetPrinterToDuplex()
SetPrinterDuplex"\\vm-print\MARS_BROTHERMFC-9460CDNonNe06:",2
EndSub
Won'tworkwithoutthefunctionSetPrinterDuplex
Lastedited:Jan22,2018
seanjon
NewMember
Joined
Dec23,2017
Messages
10
PaulKedsaid:
BTW
Code:
SubSetPrinterToDuplex()
SetPrinterDuplex"\\vm-print\MARS_BROTHERMFC-9460CDNonNe06:",2
EndSub
Won'tworkwithoutthefunctionSetPrinterDuplex
Clicktoexpand...
Iamnotunderstandingwhatyoumeanbythis.Thecodehassetprinterduplex.WhatamImissingthatyouaretellingme?Thanks
PaulKed
ActiveMember
Joined
Jun4,2015
Messages
442
Aquicksearchturnedupthisfunction:
Code:
延伸文章資訊
- 1(Access Printer.Duplex 屬性) | Microsoft Docs
Office VBA reference topic.
- 2Vba To Set Duplex Printing - I have spent... - Free Excel Help
Vba To Set Duplex Printing - I have spent hours searching for code that will ... Become a master ...
- 3Duplex printing with macros - Google Groups
I recorded a macro, and part of that macro is supposed to duplex my document when i print it. How...
- 4How to get Duplex printing working in Excel? - Stack Overflow
Since the duplex option cannot be chosen by VBA directly, you can workaround this by adding the s...
- 5Macro to print double sided - Microsoft Tech Community
The issue I am having is the sheets will not print duplex no matter what I do. ... were added 'Te...