PDA

View Full Version : Solved: Duplex on demand?



xCav8r
06-10-2005, 11:27 AM
I have a custom menu with which users can choose templates to merge with data. Some of these templates require duplex printing, but not all of them. My requirements are to send it to a new document to allow the user to save or print as desired. I know how to set duplex printing with API and also with .PrintOut, but how can I merge to a new document and set the appropriate duplex setting for that newly created document?

MOS MASTER
06-10-2005, 02:37 PM
Do it the easy way. Install another windows printer and set all the options for duplex printing in that printer.

Just change Application.ActivePrinter to print to that printer. ;)

mdmackillop
06-10-2005, 02:59 PM
I'd go along with Joost with that method. By far the simplest way, and can be utilised by any documents.

xCav8r
06-10-2005, 03:40 PM
I'll ask the IT folks about that, but I can already hear no. Any other suggestions? Is it possible, for example, to give a name to a newly created, unsaved document a la document1, document2, etc.?

MOS MASTER
06-11-2005, 11:32 AM
I'll ask the IT folks about that, but I can already hear no. Any other suggestions? Is it possible, for example, to give a name to a newly created, unsaved document a la document1, document2, etc.?
I don't know why they would say no...

Your seccond question is not clear to me could you rephrase that? :whistle:

MOS MASTER
06-11-2005, 11:36 AM
By the way this method can be used to do it all by VBA:
Click Here (http://pubs.logicalexpressions.com/Pub0009/LPMArticle.asp?ID=116)

Later..:whistle:

xCav8r
06-11-2005, 04:48 PM
The IT department at this client has said no to everything that I've asked for or suggested, and that was mostly for little stuff. They're in the habit of saying no. Asking them to install hundreds of duplicate printer drivers is virtually guaranteed to get a negative response, and I'm sure they'll be upset at me for asking, but I'm planning to do it anyway. ;)

Sorry about the way that I phrased that question. What I meant to ask was this: is it possible to control the name used for a newly created document? When I create a document in word, word always calls it document1, document2, document3, etc. If I create a newly merged document with type "letter", then it'll be letters1, letters2, letters3, etc. Is there any way to control the names given to newly created documents? If it's possible to use a word of my choice, then I could check the name of the active document against the list of ones that should be duplex vs. not, change the printer setting accordingly, send the job to the printer, and restore the default printer setting. Or perhaps there's some other way of doing that which hasn't occurred to me.

Thanks for the link. Looks like a hacked version of Microsoft's article. :*)

MOS MASTER
06-13-2005, 10:23 AM
Thanks for the link. Looks like a hacked version of Microsoft's article. :*)
O Well..we have a simple login script in the domain that gives you the networkprinters you need. (Shouldn't be that hard for a MCSE)
But I've encoured IT departments with the same attitude so I know what you mean...

Yes you can give the documents another name but then you would have to automate the entire mailmerge and you have to save the documents aswell.

And for the hacked version....It's a article from a brilliant Word MVP and he did say he had help from the Brilliant VB MVP Karl Peterson...and that person did write a lot of MS articles so yeps that could be...:rofl:

Later...

xCav8r
06-13-2005, 10:47 AM
The merge is fully automated already except I'm not saving because I was told not to do so. I know I can set the name by that way, but is there any way to override the default temporary name with my own without saving?

I was using the term hack lightly. It looked like a modified version of what I got from the MSDN to control the printer through API. I didn't mean to imply anything about the author. I have no delusions about my own knowledge of word--or lack thereof. ;)

MOS MASTER
06-13-2005, 10:59 AM
Hi, :yes

As ussual I was joking when I replied to the Hack stuff...:rofl: (Can't help myself)

To the temp name part.
Really I have no idea. If there's time I'll do some tests but I don't think you can do anything reliable to it.

But as a workarround:
Why not save everything in a tempfolder and Kill it after your done? Then you've got all the freedome in the world to use your own logics on it.

I'll think about it..:whistle:

xCav8r
06-13-2005, 11:04 AM
LOL!!!! I was just talking to the IT person in charge of the printers about duplicate drivers when the very same idea to me. I came back to post it, but you had already beaten me to it. Argh!!!!!!!! :)

I'll consider this solved. Thanks for the help.

MOS MASTER
06-13-2005, 11:07 AM
Hahaha...you crack me up!
You're Welcome! :beerchug:

xCav8r
06-14-2005, 11:53 AM
I might have come up with a better way to do this. In the BeforePrint event...


If ActiveDocument.CustomDocumentProperties("Duplex").Value = True then...


Then check to see if the printer job is done, then reset the driver to non duplex. It's still with API, but I can't see how to do it with .PrintOut without making my own custom dialog box for printing. Maybe someone else has an idea how that might be accomplished.:reading:

MOS MASTER
06-14-2005, 12:08 PM
I might have come up with a better way to do this. In the BeforePrint event...


If ActiveDocument.CustomDocumentProperties("Duplex").Value = True then...


Then check to see if the printer job is done, then reset the driver to non duplex. It's still with API, but I can't see how to do it with .PrintOut without making my own custom dialog box for printing. Maybe someone else has an idea how that might be accomplished.:reading:
Hi, :yes

Sure using a property or a variable will help identifying the right document. But to be honest so is the document name or the existens of a simple bookmark in the document.

You just need some kind of marker and there are so many to choose from so just pick the one that's the fastest. (That cuts saving out!) :rofl:

Well if your going for fully coding the duplex and not using the extra printer option then your in for a fun time.

Yes you'll always have to work with API's to get this done in Word because it's simply not part of the objectmodel (Duplex printing that is)

And if it's not in the object model you usually have to escape to API's and other stuff. (You could even Sendkey it...Not advisable I may add)

So if you do find the code that works for yah..please do post it here to share. (Or anyone who has it)

The biggest problem with the API stuff is that some things are Printer specific and not generic so you have to work out a lot of details and do mucho testing...

Well good luck to yah! :whistle:

xCav8r
06-14-2005, 12:50 PM
I thought about the document name obviously, but I didn't like having to impose naming restrictions of any kind on workgroups. I decided against the bookmark because bookmarks are so easily deleted. Saving and later killing the document is a pain, so using the document's custom properties seemed like the best place to put the setting and value.

I'm still hoping in the back of my mind that someone will unearth some easter egg in Word that reveals that duplex printing has been hidden in Word's object model all along. hehehe

MOS MASTER
06-14-2005, 01:32 PM
I'm still hoping in the back of my mind that someone will unearth some easter egg in Word that reveals that duplex printing has bene hidden in Word's object model all along. hehehe
Ah..you've been there? (Word 97) :rofl: :rotlaugh:

Well you could use a documentvariable as well.
ActiveDocument.Variables("Variable").Value = "Test"
That would be my personal favorite..:whistle:

xCav8r
06-14-2005, 01:38 PM
I'm being bombarded with new objects!!!!!!!!!!!!!! :bonk:

Actually, this looks like another good one. Thanks for the suggestion.

MOS MASTER
06-14-2005, 01:48 PM
I'm being bombarded with new objects!!!!!!!!!!!!!! :bonk:

Actually, this looks like another good one. Thanks for the suggestion.
Word has the Biggest Object model by far...so please don't get me started! :tease:

Still more ways to skin this cat but I thought I gave you my favorite one to hold data in a document. (unseen that is)

Came about this one for the duplex in my bookmark collection. (which is to big if I may add)
http://www.word.mvps.org/FAQs/MacrosVBA/SetDuplexOnOff.htm (http://www.word.mvps.org/FAQs/MacrosVBA/SetDuplexOnOff.htm)

Enjoy! :whistle:

xCav8r
06-14-2005, 01:54 PM
Yes, hidden good. I'm redoing things now. Besides, I've heard grumblings that this organization may be scrubbing all the document properties in the future, so this is a better route.

That MVP page points to the MS support page (thought it was at the MSDN before) that I grabbed the API code that I'm using. I had to modify it for--don't laugh--Novell. :rotflmao:

MOS MASTER
06-14-2005, 01:58 PM
Yes, hidden good. I'm redoing things now. Besides, I've heard grumblings that this organization may be scrubbing all the document properties in the future, so this is a better route.
Good point..happens a lot these days..there's a free addin from Microsoft to do it all for yah...(De-personalise documents)

So yes a variable would be the better method.

FYI..you can easily have the Variable displayed with a fieldcode like:
{ DOCVARIABLE "NameVariable" }

Very useful sometimes...Ok..I'm getting carried away!


That MVP page points to the MS support page (thought it was at the MSDN before) that I grabbed the API code that I'm using. I had to modify it for--don't laugh--Novell. :rotflmao:
:rotflmao::rotflmao::rotflmao::rotflmao:

xCav8r
06-14-2005, 03:46 PM
How do I get rid of variables?

xCav8r
06-14-2005, 09:54 PM
I have something working now with which I'm partially satisfied. My only frustration (not new) is that Word has no AfterPrint event, so I set duplex in the BeforePrint event, then I trap CTRL+P, File|Print, and Print (from the standard toolbar) to show the Print Dialog after which I know the print file has been sent and can reset the printer driver to non-duplex.

Perhaps I'll clean up the code a bit and submit this as my first KB entry. :*)

MOS MASTER
06-15-2005, 09:25 AM
How do I get rid of variables?
activedocument.Variables("joost").Delete

MOS MASTER
06-15-2005, 09:27 AM
Perhaps I'll clean up the code a bit and submit this as my first KB entry. :*)
Yess please do that..it would be an add to have a good duplex entry...I'd love to Approve it! :yes (make sure it has good test files)

xCav8r
06-15-2005, 09:34 AM
activedocument.Variables("joost").Delete

I was blind, but now I see!!!!! :o:

MOS MASTER
06-15-2005, 09:41 AM
activedocument.Variables("joost").Delete

I was blind, but now I see!!!!! :o:
Well I've cleaned my glasses as well so I'm also good to go! :rofl:

Till infinity and beyond! :whistle:

xCav8r
06-17-2005, 08:15 AM
I'm testing the "duplex on demand" that I created, and I'm coming across something that I've had happen to me before that I don't understand. Something is causing my application events to stop firing. I'm not opening anything new or closing anything; they just seem to stop working, and I have to manually reinitialize my event handler to get them working again. Has anyone else experienced this?

MOS MASTER
06-18-2005, 11:02 AM
I'm testing the "duplex on demand" that I created, and I'm coming across something that I've had happen to me before that I don't understand. Something is causing my application events to stop firing. I'm not opening anything new or closing anything; they just seem to stop working, and I have to manually reinitialize my event handler to get them working again. Has anyone else experienced this?
In My experience that will only happen if you're playing with your code/debugging it.

If you let the program run you will not have this problem.

:whistle:

xCav8r
06-18-2005, 12:55 PM
Good to know. Thanks.

MOS MASTER
06-18-2005, 01:02 PM
Good to know. Thanks.
You're welcome! :beerchug: