|
-
Mar 6th, 2006, 12:13 PM
#1
Thread Starter
Lively Member
Print settings - API?
Hi,
I need a macro that changes an active documents print settings for MS Word 97 so that the following is selected:
- 1 sided printing
- Page 1 Tray 1
- Page 2 Tray 2
- Page 3+ Tray 4
Is this possible?
thanks
Last edited by rocket0612; Mar 6th, 2006 at 02:46 PM.
The Box Said: "You need Windows Vista or better" ... So I Installed LiNUX 
-
Mar 6th, 2006, 02:18 PM
#2
Frenzied Member
Re: Print settings
I know that you can use VBA code select the printer to use for a specific job, but to go beyond that and select particular features of the printer will probably require Windows API calls (?). At least I couldn't figure out any other way to do it. Maybe someone with API experience can help. You may have to repost this with "API" in the title.
Blessings in abundance,
All the Best,
& ENJOY!
Art . . . . Carlisle, PA . . USA
-
Mar 6th, 2006, 02:46 PM
#3
Thread Starter
Lively Member
Re: Print settings - API?
thanks for the reply, haven't a clue what API is but have renamed the title!
The Box Said: "You need Windows Vista or better" ... So I Installed LiNUX 
-
Mar 7th, 2006, 03:41 AM
#4
Thread Starter
Lively Member
Re: Print settings - API?
I have found this sample code but it errors when it gets to ' .DefaultTray = "Tray 2"':
VB Code:
Dim sCurrentPrinter As String
sCurrentPrinter = ActivePrinter
wrd.ActivePrinter = "\\BTBEAPAPP03\PBTBEA00001M"
wrd.With Options
.DefaultTray = "Tray 2"
End With
Application.PrintOut FileName:=""
wrd.With Options
.DefaultTray = "Use printer settings"
End With
ActivePrinter = sCurrentPrinter
any suggestions?
thanks
The Box Said: "You need Windows Vista or better" ... So I Installed LiNUX 
-
Mar 7th, 2006, 04:37 AM
#5
Re: Print settings - API?
Dont use the text property - "Tray 2"
VB Code:
'Const wdPrinterDefaultBin = 0
'Const wdPrinterUpperBin = 1
'Const wdPrinterLowerBin = 2
'Const wdPrinterMiddleBin = 3
'Const wdPrinterManualFeed = 4
Options.DefaultTrayID = wdPrinterUpperBin
ActiveDocument.PrintOut
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Mar 7th, 2006, 06:26 AM
#6
Thread Starter
Lively Member
Re: Print settings - API?
thanks for the reply,
I now have this:
VB Code:
Dim sCurrentPrinter As String
sCurrentPrinter = ActivePrinter
wrd.ActivePrinter = "\\BTBEAPAPP04\PBTBEA00004M"
Const WdPrinterLowerbin = 2
wrd.Options.DefaultTrayID = WdPrinterLowerbin
wrd.Application.PrintOut FileName:=""
however, it isn't selecting the tray.
Maybe I am along the wrong lines here. The problem is, the document when opened and printed automatically prints out on tray 1 for the first 2 pages, then tried to print the rest from the side feed but I can't figure out how to change this. When I go into print properties, it just has the paper source as auto so I think it has the print properties stored somewhere to default to the settings above?
thanks
The Box Said: "You need Windows Vista or better" ... So I Installed LiNUX 
-
Mar 7th, 2006, 08:42 AM
#7
Re: Print settings - API?
Did you try the other constants I posted in my code? There are 15 different constants in all but these 5 are the most relevant.
wdPrinterDefaultBin
Or
wdPrinterManualFeed
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Mar 7th, 2006, 09:35 AM
#8
Thread Starter
Lively Member
Re: Print settings - API?
thanks robdog, yeah, played abut and it seems to be working better, just need to figure which constants to use, we have big multifuntional printers with 4 trays and a side large bin, figured out the large side bin is wdPrinterLargeCapacityBin and got it printing from there. so, just a little playing about needed!
How can I get it now to only print page1 from one try, page 2 from another & the rest from another as the code I have prints it all from the same tray?
many thanks, I appreciate the help as this was driving me crazy
The Box Said: "You need Windows Vista or better" ... So I Installed LiNUX 
-
Mar 7th, 2006, 10:00 AM
#9
Re: Print settings - API?
VB Code:
Options.DefaultTrayID = wdPrinterLargeCapacityBin
ActiveDocument.PrintOut , , Range:=wdPrintFromTo, From:=1, To:=1
Options.DefaultTrayID = wdPrinterLowerBin
ActiveDocument.PrintOut , , Range:=wdPrintFromTo, From:=2, To:=2
Options.DefaultTrayID = wdPrinterUpperBin
ActiveDocument.PrintOut , , Range:=wdPrintFromTo, From:=3, To:=5
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Mar 7th, 2006, 11:20 AM
#10
Frenzied Member
Re: Print settings - API?
RobDog ...
Where did you ever pick up all of this minutiae/trivia ??? Are you an escapee from Redmond?
I tried to rate your post (positively?) but the system is tired of my giving you credit.
Blessings in abundance,
All the Best,
& ENJOY!
Art . . . . Carlisle, PA . . USA
-
Mar 7th, 2006, 11:36 AM
#11
Re: Print settings - API?
No, but I think I will be going over there next year. I'll say hi to Bill for you.
I guess it just comes from the love of Office and automating it. I have learned over the years how the object library is all put together and what it mostly consists of so with a little searching I can find most stuff fast (if I dont remember it). Then its just testing what the poster needs solving and post to vbf. 
Plus, I have many programs and utilities I have written over the years so I can usually pull some code or functions from them and create a sample.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Mar 7th, 2006, 12:44 PM
#12
Thread Starter
Lively Member
Re: Print settings - API?
thanks Robdog,
I've worked out what paper trays I need.
I'm now getting a run-time error on the line:
VB Code:
wrd.ActiveDocument.PrintOut , , Range:=wdPrintFromTo, From:=1, To:=1
Run-Time error '5148'
the number must be between -32765 and 32767
any ideas?
thanks alot
The Box Said: "You need Windows Vista or better" ... So I Installed LiNUX 
-
Mar 7th, 2006, 01:01 PM
#13
Re: Print settings - API?
Oh, its because its not a range. Only a single page. There is another setting for that.
wdPrintCurrentPage
Then also try with double quotes around the page value.
VB Code:
Range:=wdPrintFromTo, From:="1", To:="3"
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Mar 8th, 2006, 05:59 AM
#14
Thread Starter
Lively Member
Re: Print settings - API?
Robdog,
get the range error again for:
VB Code:
wrd.ActiveDocument.PrintOut , , Range:=wdPrintFromTo, _
From:="1", To:="2"
and for this wdPrintCurrentPage I get the same.
Maybe I should have mentioned I am opening word from excel, would this make a difference?
I recorded a macro in word to print the pages 1 & 2 and I get this:
[Highlight=VB]Application.PrintOut FileName:="", Range:=wdPrintRangeOfPages, Item:= _
wdPrintDocumentContent, Copies:=1, Pages:="1-2", PageType:= _
wdPrintAllPages, Collate:=True, Background:=True, PrintToFile:=FalseVBCODE]
could me alter this in anyway maybe?
thanks
The Box Said: "You need Windows Vista or better" ... So I Installed LiNUX 
-
Mar 8th, 2006, 06:06 AM
#15
Re: Print settings - API?
VB Code:
wrd.ActiveDocument.PrintOut FileName:="", Range:=wdPrintRangeOfPages, Item:=wdPrintDocumentContent, Copies:=1, Pages:="1-2", Background:=True, PrintToFile:=False
For printing a range but I'm not sure about the parameter wdPrintAllPages for PageType
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|