execution is non-linear?

B

bikuta

I've been puzzling over this for a while.

I've created a print macro which allow for duplex printing. A brief skeleton
looks like this:

1. User selects printer
2. User selects paper type
3. Printer settings are applied
4. Print out document

Sometimes the printer would (seem to) prematurely print before the settings
have been successfully applied.

I've tried stepping through the code and at one stage I actually need to run
a macro within this macro. As I step through the code once reaching the run
macro command, the debugger just decides to run the rest of the application.
This seems strange as normally when you debug an application it would just
step through once the command is complete. By calling this external macro,
has this caused another thread to start or what?

Does anyone know why this behaviour occurs?
 
D

Doug Robbins - Word MVP

Make sure that you have the Background attribute of the PrintOut command set
to False

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
B

bikuta via OfficeKB.com

It looks like the cause of the problem is Word not reading the printer
settings in Windows.
We tried upgrading Word 2k3 to SP2 but it's still not working.

So any ideas why when we have Word 2k3 open and the printer settings are
changed (i.e. in Printers & Faxes control panel), going into File -> Print,
then printer properties does not reflect the change we made to the printer
settings in the control panel.

We've tested it and the macro is fine as long as Word is able to read the
settings for the printer correctly.
 
J

Jonathan West

bikuta via OfficeKB.com said:
It looks like the cause of the problem is Word not reading the printer
settings in Windows.
We tried upgrading Word 2k3 to SP2 but it's still not working.

What code are you using to read the printer settings? Or are you simply
waiting until the user has changed the settings and then printing using
whatever the settings have been changed to?


--
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
 
B

bikuta via OfficeKB.com

Jonathan said:
What code are you using to read the printer settings? Or are you simply
waiting until the user has changed the settings and then printing using
whatever the settings have been changed to?

Well I don't believe it is related to the code as the test I performed was
through the Print menu in Word itself (macro was not used). These are the
steps I took (with single-sided printing as the default)

1. Open Word 2003
2. Check the print properties in Word -> yes it is single-sided
3. Change the printing preferences in the Windows control panel from single-
sided to double-sided.
4. Check the print properties in Word -> it's NOT double-sided, still single-
sided
5. Relaunch Word 2003
6. Check printer properties in Word -> yes it has now read the correct
settings

Is this a bug in Word? Is there a fix/patch for it?
 
J

Jonathan West

bikuta via OfficeKB.com said:
Well I don't believe it is related to the code as the test I performed was
through the Print menu in Word itself (macro was not used). These are the
steps I took (with single-sided printing as the default)

1. Open Word 2003
2. Check the print properties in Word -> yes it is single-sided
3. Change the printing preferences in the Windows control panel from
single-
sided to double-sided.

That's your mistake.
4. Check the print properties in Word -> it's NOT double-sided, still
single-
sided

Instead change the setting in Word itself in this dialog
5. Relaunch Word 2003
6. Check printer properties in Word -> yes it has now read the correct
settings


--
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
 
B

bikuta via OfficeKB.com

I thought there was no way of changing the duplex setting in a macro except
through the Windows API and this means changing the Windows printer settings
directly (i.e. not just for Word).

If I want to change it for Word only, how could I do this?

After installing all the latest office updates Word is now reading the
printer settings correctly. However if there was a way to change the settings
only in Word that would be useful.

Jonathan said:
[quoted text clipped - 13 lines]
single-
sided to double-sided.

That's your mistake.
4. Check the print properties in Word -> it's NOT double-sided, still
single-
sided

Instead change the setting in Word itself in this dialog
5. Relaunch Word 2003
6. Check printer properties in Word -> yes it has now read the correct
settings
 
J

Jonathan West

bikuta via OfficeKB.com said:
I thought there was no way of changing the duplex setting in a macro except
through the Windows API and this means changing the Windows printer
settings
directly (i.e. not just for Word).

If I want to change it for Word only, how could I do this?

Note the current settings, change them through the API, print, change them
back.

This article will help

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

It is a shortcoming in Word that it doesn't have a proper printer handling
object model - even though Access does. It has been the subject of feedback
from the MVPs to Microsoft for a couple of versions now!
 
B

bikuta via OfficeKB.com

That article is the one I have been using.
Except mine has some extra things because with Canon printers they have their
own library to change printer settings (as far as I know Canon printer
settings can't be changed through the Win32 API).

However we still sometimes experience issues where the printer would not
print with the correct settings unless it is set as the default printer.
Other than this everything seems to be ok.
 
J

Jonathan West

bikuta via OfficeKB.com said:
That article is the one I have been using.
Except mine has some extra things because with Canon printers they have
their
own library to change printer settings (as far as I know Canon printer
settings can't be changed through the Win32 API).

That is additional information I didn't have. If you still need further
information, you will need to contact Canon to see if they will release
details of how to call that library. I'm afraid I don't have those details.
However we still sometimes experience issues where the printer would not
print with the correct settings unless it is set as the default printer.
Other than this everything seems to be ok.

Yes, this does sometimes happen.
 
B

bikuta via OfficeKB.com

Jonathan said:
That is additional information I didn't have. If you still need further
information, you will need to contact Canon to see if they will release
details of how to call that library. I'm afraid I don't have those details.


Yes, this does sometimes happen.

Is there any way to avoid it?
 
B

bikuta via OfficeKB.com

Jonathan said:
[quoted text clipped - 3 lines]
Is there any way to avoid it?

Have your code note the default printer, change the default, print, change
back.

By this you mean changing the value for Word.ActivePrinter to the printer I
want to print to? If this is what you mean, I'm already doing this.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top