C
Chris
We are developing a Java application and using VB and VBA
code to perform a mail merge and then print. We are
successfully using a JSP to run a VB module which performs
a mail merge. We are trying to use VBA code to
automatically print the mail merge doc while it is
embedded in a browser window. We have macro code which
will print the document, but it will not shut down Word or
the IE window after it is printed. It appears to me that
once the Word VBA code to print is executed, the document
is no longer recognized as a Word doc, therefore any Word
VBA code set to run after the print statement will not
run. I know this is not the best print solution, but it
was what I have to work with. Here is the code which
generates a "4237 runtime error, command is not available"
after ActiveDocument.PrintOut when it tries to run
ActiveWindow.Close False:
Sub printclose()
Application.Visible = False
ActiveDocument.PrintOut
ActiveWindow.Close False
ActiveDocument.Close False
Application.OnTime _
when:=Now + TimeValue("00:0:15"), _
Name:="wantquit"
End Sub
Any ideas? I thought maybe I could work with the
InternetExplorer.Application object, but I need code to
recognize the existing object, can't get it to work with
CreateObject. By the way, I normally have this code in
the Autpen sub, I put it in a different sub for testing
purposes.
Thanks,
Chris
code to perform a mail merge and then print. We are
successfully using a JSP to run a VB module which performs
a mail merge. We are trying to use VBA code to
automatically print the mail merge doc while it is
embedded in a browser window. We have macro code which
will print the document, but it will not shut down Word or
the IE window after it is printed. It appears to me that
once the Word VBA code to print is executed, the document
is no longer recognized as a Word doc, therefore any Word
VBA code set to run after the print statement will not
run. I know this is not the best print solution, but it
was what I have to work with. Here is the code which
generates a "4237 runtime error, command is not available"
after ActiveDocument.PrintOut when it tries to run
ActiveWindow.Close False:
Sub printclose()
Application.Visible = False
ActiveDocument.PrintOut
ActiveWindow.Close False
ActiveDocument.Close False
Application.OnTime _
when:=Now + TimeValue("00:0:15"), _
Name:="wantquit"
End Sub
Any ideas? I thought maybe I could work with the
InternetExplorer.Application object, but I need code to
recognize the existing object, can't get it to work with
CreateObject. By the way, I normally have this code in
the Autpen sub, I put it in a different sub for testing
purposes.
Thanks,
Chris