msword macro pause

T

timc

i am opening a word document, printing the document and then closing msword
from a batch file. the batch file language uses msword macro commands.
however, the filecloseall command happens too fast after the fileprintdefault
command that i get a "word is trying to print..closing word will cancel
print" error message. in an attempt to make the program wait, i have inserted
a pause function after the fileprintdefault command. however, now the macro
waits before telling me that the "word is trying to print...". is there a way
to pause word while the print is spooling and then close the program?
 
J

Jonathan West

timc said:
i am opening a word document, printing the document and then closing msword
from a batch file. the batch file language uses msword macro commands.
however, the filecloseall command happens too fast after the
fileprintdefault
command that i get a "word is trying to print..closing word will cancel
print" error message. in an attempt to make the program wait, i have
inserted
a pause function after the fileprintdefault command. however, now the
macro
waits before telling me that the "word is trying to print...". is there a
way
to pause word while the print is spooling and then close the program?

How to find out whether Word has finished printing
http://www.word.mvps.org/FAQs/MacrosVBA/WaitForPrint.htm


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

timc

the document now prints but i still get the same message, while printing is
happening, about word trying to print and exiting word. i placed the false
background print statement in the pause macro. i was unable to enable the
edit button within word for the word command "fileprintdefault".
 
J

Jonathan West

timc said:
the document now prints but i still get the same message, while printing
is
happening, about word trying to print and exiting word. i placed the false
background print statement in the pause macro. i was unable to enable the
edit button within word for the word command "fileprintdefault".

Could you show us the code you are using to do the printing and exit?


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

timc

from within the batchfile i call msword and load the document. i then follow
with the macro m/fileprintdefault, i then pause the macro with :
"Public Declare Sub Sleep Lib "kernel32" _
(ByVal dwMilliseconds As Long)


Sub PauseMacroAfterPrinting()
ActiveDocument.PrintOut Background:=False


End Sub"

i then exit using the word document macro m/filecloseall

i appears that i am unable to edit any preprogrammed macro that is installed
with msword. if i could, i would insert the print background command in the
fileprintdefault macro.
 
T

timc

the batch file reads as:
" "C:\Program Files\Microsoft Office\Office\WINWord.exe"
u:\public\FallMedsPatientList /mfileprintdefault /mpausemacroafterprinting
/mfileexit
exit"

and the PauseMacroAfterPrinting macro i assume is stored somewhere in
microsoft word. i recorded it in word and used savednormal (Ctrl S). a
search of the drive looking for "*pausemacro*.*" did not return any results.
the "fileprintdefault" and "fileexit" macors are preprogrammed and included
in msword.
 
S

Shell

In response to the post:
the batch file reads as:
" "C:\Program Files\Microsoft Office\Office\WINWord.exe"
u:\public\FallMedsPatientList /mfileprintdefault /mpausemacroafterprinting
/mfileexit
exit"

and the PauseMacroAfterPrinting macro i assume is stored somewhere in
microsoft word. i recorded it in word and used savednormal (Ctrl S). a
search of the drive looking for "*pausemacro*.*" did not return any results.
the "fileprintdefault" and "fileexit" macors are preprogrammed and included
in msword.

If this is all you have in the batch file, then I would move the file
exit process to inside the "mpausemacroafterprinting" macro. Use the
procedure to watch for the "end of print" and exit Word from there.
Let the Batch file end after starting Word and getting the printing
started.

HTH
Shell
 
T

timc

i am very ill skilled at writing code. i am not sure of how to exit the
program from the macro or even to watch for "end of print". i placed
"fileexit" in the macro and got and error. same for endofprint. i think you
nomenclature may be erroneous. your help would be greatly appreciated.
 
S

Shell

In response to the post:
i am very ill skilled at writing code. i am not sure of how to exit the
program from the macro or even to watch for "end of print". i placed
"fileexit" in the macro and got and error. same for endofprint. i think you
nomenclature may be erroneous. your help would be greatly appreciated.

"FileExit" is not a command, it's a method which requires programming.
I'm sorry, I assumed you had some level of programming experience. As
Jonathan West pointed out in the link he provided, Word is often used
by other programs to "print" documents, and in doing so (because Word
prints in Background) may attempt to close Word before the print
function is complete.

You described the process as using certain macros to complete the
process, /mfileprintdefault /mpausemacroafterprinting /mfileexit. If
you could post the content of those macros it would be simple to
insert the appropriate code to wait for completion of printing before
attempting to "exit".

In effect, what I propose is to change the Batch file so it does NOT
exit the program. It would just start Word with the document to
print, then in the last macro tell Word to exit.

So, let's see what is in the macros,
Shell
 
T

timc

i would like to open and edit the macros. the print and close macros are
preprogrammed in word and the edit but is greyed out. they are protected
somehow within word (unless there is another way to view them).
 
S

Shell

In response to the post:
i would like to open and edit the macros. the print and close macros are
preprogrammed in word and the edit but is greyed out. they are protected
somehow within word (unless there is another way to view them).

Sorry, the only way to get the results you're looking for is by
editing one of the macros, or making a new one that can be addressed
to watch for the end of print event (or take printing out of
background).

If you can't edit the macros, or create a new one, you're toast.
Shell
 

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