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 / October 2006

Tip: Looking for answers? Try searching our database.

Why WinWord does not end after I am done with the printing and clo

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Jeffery B Paarsa - 05 Oct 2006 23:59 GMT
Hello,

I start Word by double clicking on a Word template of .dot “Assuming Winword
is not listed in my task manager window either on the Applications tab or
Processes tab” before I do this double clicking.  AutoNew macro will kick off
by hiding the Application and displaying the Userform and following code will
be executed:
Private Sub CMDPrint_Click()
  ‘  some codes for editing etc….
   NPPkg.Hide
   WordBasic.DisableAutoMacros 1
   Call openHippa(NPPkg.PFName.Text, NPPkg.PLName.Text)
   Call openMedHistory(NPPkg.PFName.Text, NPPkg.PLName.Text,
NPPkg.PVDate.Text)
   Call openRegInfo(NPPkg.PFName.Text, NPPkg.PLName.Text, NPPkg.PVDate.Text)
   Call openProgNote(NPPkg.PFName.Text, NPPkg.PLName.Text, NPPkg.PVDate.Text)
   If NPPkg.ProbList.Value = True Then
      Call openProbList(NPPkg.PFName.Text, NPPkg.PLName.Text,
NPPkg.PVDate.Text)
   End If
   WordBasic.DisableAutoMacros 0
   .Protect wdAllowOnlyFormFields, Noreset:=True
   .Close wdDoNotSaveChanges
 End With
End Sub
Sub openHippa(ByRef PFName As String, ByRef PLName As String)
 Dim HippaForm As Document
'  WordBasic.DisableAutoMacros 1
 Set HippaForm = Word.Documents.Add(Template:=FileSystem.CurDir +
"\(MR)Hippa Form.dot", Visible:=False)
 With HippaForm
   .Unprotect
   Call UpdHeadFoot
   .Bookmarks("PFName").Range _
   .InsertBefore PFName
   .Bookmarks("PFName").Range.Font.Color = wdColorRed
   .Bookmarks("PLName").Range _
   .InsertBefore PLName
   .Bookmarks("PLName").Range.Font.Color = wdColorRed
   ActiveDocument.Fields.Update
   .Protect wdAllowOnlyFormFields, Noreset:=True
   .PrintOut
   .Close wdDoNotSaveChanges
 End With
End Sub

All the other subroutines of openMedHistory, openRegInfo, openProgNote and
openProbList are almost identical to openHippa code that you will see above,
except UpdHeadFoot which is for updating Header/Footer section for each
document.  While I am watching the directory I can see that all the temporary
~$R)….files will be created and after a few second will be eliminated after
the printout was spooled for the printer.  For the first round I have no
problem and all my 4-5 documents will be printed with no problem.  But after
eliminating the temporary ~$R)… files and spooling the printouts I don’t see
the Winword on the Task manager Applications window tab but I still can see
the WinWord running on the Task manager Processes tab.  Now if I do the same
act of double clicking on the same Word template .dot I will get the
following dialog error:  
Run-time error ‘5151’;

Word was unable to read this document.  It may be corrupt.
Try one or more of the following:
*Open and Repair the file.
*Open the file with the Text Recovery converter.

Now if I terminate the Process tree for the WinWord thru the task manager
then I would be able to run and print my documents one more time without any
error dialog but the second time I have the same problem.  Basically between
each print I have to terminate the WinWord thru the task manager to be able
to get the next round of printing!  Looking at the directory of my word
templates on the “Date Modified” field I don’t see any changes/corruption
that may have been applied to my Word templates, so accidental corruption is
out of picture.

Question:  Why won’t WinWord does not terminate even though I explicitly
close the documents?  How can I force this termination thru the VBA macro

Signature

Jeff B Paarsa

Doug Robbins - Word MVP - 06 Oct 2006 04:36 GMT
I do not see anywhere in your code where you are quitting the application.
Use an Application.Quit command

Signature

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

> Hello,
>
[quoted text clipped - 88 lines]
> Question:  Why won't WinWord does not terminate even though I explicitly
> close the documents?  How can I force this termination thru the VBA macro
Jeffery B Paarsa - 06 Oct 2006 16:46 GMT
Thanks a lot.
Signature

Jeff B Paarsa

> I do not see anywhere in your code where you are quitting the application.
> Use an Application.Quit command
[quoted text clipped - 91 lines]
> > Question:  Why won't WinWord does not terminate even though I explicitly
> > close the documents?  How can I force this termination thru the VBA macro
 
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.