Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / August 2006

Tip: Looking for answers? Try searching our database.

Default printer changing

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Addy - 14 Jun 2006 16:41 GMT
I have loads of printing macros which are all working great now thanks to
help from this site.  I have a macro which opens up the dialog box of a
colour photocopier so that you can do any special printing such as duplex,
staple, holepunch etc.  The macro seems to be sticking to the colour printer
and so when I use one of the other macros to print to the laser printer it
prints to teh colour printer.  Anyone any ideas why please. My macro is below
cheers in advance

Private Sub CMDCOLSPECIAL_Click()
   
   With Dialogs(wdDialogFilePrintSetup)
   .Printer = "\\rother\Canon"
   .DoNotSetAsSysDefault = True
   .Execute
 
   Dialogs(wdDialogFilePrint).Show
     
End With

End Sub
Jonathan West - 14 Jun 2006 17:14 GMT
>I have loads of printing macros which are all working great now thanks to
> help from this site.  I have a macro which opens up the dialog box of a
[quoted text clipped - 18 lines]
>
> End Sub

Hi Addy,

You need to find out what printer is in use already, and change it back
after. Something like this

Private Sub CMDCOLSPECIAL_Click()
Dim sPrinter as String

   With Dialogs(wdDialogFilePrintSetup)
   sPrinter = .Printer
   .Printer = "\\rother\Canon"
   .DoNotSetAsSysDefault = True
   .Execute

   Dialogs(wdDialogFilePrint).Show

   .Printer = sPrinter
   .DoNotSetAsSysDefault = True
   .Execute

End With

End Sub

Signature

Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org 

Addy - 28 Jun 2006 11:31 GMT
Many thanks. I did think of that but the only problem is that we have 2 laser
printers in our dpt running on this macro.  I did try way back changing the
printer to the canon printer then changing it back with the code below

ActivePrinter = "\\rother\lex1340"
Else
ActivePrinter = "\\rother\lex1435"
   
but it only defaulted to LEX1340 or nothing if that printer wasn't
installed.  Any other ideas please?

cheers

> >I have loads of printing macros which are all working great now thanks to
> > help from this site.  I have a macro which opens up the dialog box of a
[quoted text clipped - 42 lines]
>
> End Sub
Graham Mayor - 28 Jun 2006 13:22 GMT
The point of Jonathan's code is that the original printer information is
captured then later restored. It shouldn't matter what the printer was
originally ?

Signature

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor -  Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>

> Many thanks. I did think of that but the only problem is that we have
> 2 laser printers in our dpt running on this macro.  I did try way
[quoted text clipped - 64 lines]
>> Keep your VBA code safe, sign the ClassicVB petition
>> www.classicvb.org 
Addy - 15 Jun 2006 09:26 GMT
Many thanks. I did think of that but the only problem is that we have 2 laser
printers in our dpt running on this macro.  I did try way back changing the
printer to the canon printer then changing it back wtih the code below

ActivePrinter = "\\rother\lex1340"
Else
ActivePrinter = "\\rother\lex1435"
   
but it only defaulted to LEX1340 or nothing if that printer wasn't
installed.  Any other ideas

cheers

> I have loads of printing macros which are all working great now thanks to
> help from this site.  I have a macro which opens up the dialog box of a
[quoted text clipped - 16 lines]
>
> End Sub
Addy - 28 Jun 2006 13:53 GMT
Apologies Jonathan & Graham.  I didn't read your code correctly.  I've now
pasted it in my macro and it works a dream.  Apologies I am a novice and
struggling a bit sometimes.  

Once the special macro is used and you print duplex, staple, holepunch etc
do you know if there's a code to set the printer back to default? I don't
think there will be as there are no macros for special printing such as
duplex, staple etc hence the need for a special printing macro which just
takes you to the relevant printer.

Any help is greatly appreciated.

Many thanks

> I have loads of printing macros which are all working great now thanks to
> help from this site.  I have a macro which opens up the dialog box of a
[quoted text clipped - 16 lines]
>
> End Sub
Jonathan West - 28 Jun 2006 15:11 GMT
> Apologies Jonathan & Graham.  I didn't read your code correctly.  I've now
> pasted it in my macro and it works a dream.  Apologies I am a novice and
[quoted text clipped - 7 lines]
>
> Any help is greatly appreciated.

Hi Addy

That is trickier. The whole issue of controlling the printer settings
through VBA is rather fraught. It *can* be done, and I have written a series
of articles on the topic.

The starting point for doing this is that for network printers, you *must*
install a local copy of the printer driver on the workstation.

Here are the articles

Controlling the Printer from Word VBA
Part 1: Using VBA to Select the Paper Tray
http://pubs.logicalexpressions.com/Pub0009/LPMArticle.asp?ID=101

Controlling the Printer from Word VBA
Part 2: Using VBA to control Duplex, Color Mode and Print Quality
http://pubs.logicalexpressions.com/Pub0009/LPMArticle.asp?ID=116

Controlling the Printer from Word VBA
Part 3: Dealing with Different Paper Sizes
http://pubs.logicalexpressions.com/Pub0009/LPMArticle.asp?ID=132

Controlling the Printer from Word VBA
Part 4: Getting printer driver details
http://pubs.logicalexpressions.com/Pub0009/LPMArticle.asp?ID=183

Signature

Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org 

Graham Mayor - 28 Jun 2006 15:40 GMT
You can create macros to set the duplex option etc. See if the examples at
http://www.gmayor.com/fax_from_word.htm put you on course.

You could also setup a number of different versions of  the printer drivers
with different parameters pre-set if you want and call them as required.
or
You could address the Printer's PCL language directly using Print fields in
the document eg

Sub PrintDuplex()
Selection.Fields.Add Range:=Selection.Range, _
Type:=wdFieldEmpty, Text:="PRINT 27""&l1S""", PreserveFormatting:=False
End Sub

Will insert a duplex Print field in the document.

Signature

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor -  Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>

> Apologies Jonathan & Graham.  I didn't read your code correctly.
> I've now pasted it in my macro and it works a dream.  Apologies I am
[quoted text clipped - 31 lines]
>>
>> End Sub
JayM - 16 Aug 2006 13:11 GMT
Graham

I am trying to use the PRINT field in my macro to print duplex.  This works
very well unless the document has a header or footer in which case it throws
the header/footer onto another page.

Any help would be appreciated.

I have looked at Jonathan West's articles but i am just confused by the
whole thing.  - That's the problem with being a novice

> You can create macros to set the duplex option etc. See if the examples at
> http://www.gmayor.com/fax_from_word.htm put you on course.
[quoted text clipped - 47 lines]
> >>
> >> End Sub
Graham Mayor - 16 Aug 2006 14:04 GMT
As you have found, print fields work OK if there is no conflict with the
complexity of the document and I don't have access to a duplexing printer to
test your methodology. However print fields go in the document, not in
macros. The macro I quoted is merely to simplify the insertion of such a
field.

In the circumstances my suggestion to create a duplicate printer driver with
the duplex option set and use the method suggested in the previously posted
link http://www.gmayor.com/fax_from_word.htm to switch printers would be the
least problematic solution.

Signature

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor -  Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>

> Graham
>
[quoted text clipped - 67 lines]
>>>>
>>>> End Sub
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.