E
Edmund
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
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