![]() |
Closing WINWORD.EXE from Excel VBA when my main proc ends
My main proc in Excel calls the below sample sub proc (which uses Word VBA),
each time main proc runs. However, I realize Windows Task Manager seem to display many instances of "WINWORD.EXE" even after I close & exit Excel Application. How can I close "WINWORD.EXE" each time sub proc ends? Sub MainProc() Call SaveACopyToLocal_Fix_CRLF_UNIX_Bug(iFN:=iPath & "\" & iFN_isbp004, iReadOnly:=True, iFormat:=0, iEncoding:=1252, oFN:=oPath & "\" & oFN_isbp004, oFileFormat:=2, oAddToRecentFiles:=True, oEncoding:=437, oLineEnding:=0) End Sub Private Sub SaveACopyToLocal_Fix_CRLF_UNIX_Bug(iFN As String, iReadOnly As Boolean, iFormat As Integer, iEncoding As Integer, oFN As String, oFileFormat As Integer, oAddToRecentFiles As Boolean, oEncoding As Integer, oLineEnding As Integer) Dim WordApp As Object Set WordApp = CreateObject("Word.Application") On Error GoTo ErrorHandler: With WordApp .Documents.Open Filename:=iFN, ReadOnly:=iReadOnly, Format:=iFormat, Encoding:=iEncoding .ActiveDocument.SaveAs Filename:=oFN, FileFormat:=oFileFormat, AddToRecentFiles:=oAddToRecentFiles, Encoding:=oEncoding, LineEnding:=oLineEnding .Documents(oFN).Close False End With Set WordApp = Nothing Exit Sub ErrorHandler: Msg = "Please ensure that you are properly connected to the server " & vbCrLf Msg = Msg & "before attemting to rerun this application. " MsgBox Msg, vbCritical, APPNAME & " (UNABLE TO CONTACT SERVER)" End Sub Thanks -- Edmund (Using Excel 2003) |
Closing WINWORD.EXE from Excel VBA when my main proc ends
Forgot to specify that the many instances of "WINWORD.EXE" which appears in
Windows Task Manager are found in tabname "Processees" instead of tab name "Application". -- Edmund (Using Excel XP) |
Closing WINWORD.EXE from Excel VBA when my main proc ends
WordApp.Quit Set WordApp = Nothing -- Jim Cone San Francisco, USA http://www.realezsites.com/bus/primitivesoftware (Excel Add-ins / Excel Programming) "Edmund" wrote in message My main proc in Excel calls the below sample sub proc (which uses Word VBA), each time main proc runs. However, I realize Windows Task Manager seem to display many instances of "WINWORD.EXE" even after I close & exit Excel Application. How can I close "WINWORD.EXE" each time sub proc ends? Sub MainProc() Call SaveACopyToLocal_Fix_CRLF_UNIX_Bug(iFN:=iPath & "\" & iFN_isbp004, iReadOnly:=True, iFormat:=0, iEncoding:=1252, oFN:=oPath & "\" & oFN_isbp004, oFileFormat:=2, oAddToRecentFiles:=True, oEncoding:=437, oLineEnding:=0) End Sub Private Sub SaveACopyToLocal_Fix_CRLF_UNIX_Bug(iFN As String, iReadOnly As Boolean, iFormat As Integer, iEncoding As Integer, oFN As String, oFileFormat As Integer, oAddToRecentFiles As Boolean, oEncoding As Integer, oLineEnding As Integer) Dim WordApp As Object Set WordApp = CreateObject("Word.Application") On Error GoTo ErrorHandler: With WordApp .Documents.Open Filename:=iFN, ReadOnly:=iReadOnly, Format:=iFormat, Encoding:=iEncoding .ActiveDocument.SaveAs Filename:=oFN, FileFormat:=oFileFormat, AddToRecentFiles:=oAddToRecentFiles, Encoding:=oEncoding, LineEnding:=oLineEnding .Documents(oFN).Close False End With Set WordApp = Nothing Exit Sub ErrorHandler: Msg = "Please ensure that you are properly connected to the server " & vbCrLf Msg = Msg & "before attemting to rerun this application. " MsgBox Msg, vbCritical, APPNAME & " (UNABLE TO CONTACT SERVER)" End Sub Thanks -- Edmund (Using Excel 2003) |
All times are GMT +1. The time now is 10:29 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com