LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 62
Default 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)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
running proc in excel just_real Excel Discussion (Misc queries) 1 November 21st 08 06:51 AM
executing stored proc from Excel doofy Excel Programming 2 June 5th 07 06:43 PM
Paste in WinWord, problems with several processes lasse g Excel Programming 2 March 3rd 05 03:37 PM
Open Winword from Excel Robert Christie[_3_] Excel Programming 2 February 14th 04 04:27 AM
Open Winword-file using a Excel 97 VBA macro Dominik Scheck Excel Programming 4 August 5th 03 02:35 AM


All times are GMT +1. The time now is 09:34 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"