-
Solved: Closing Excel from Word
In my ongoing TextSelect utility, (posted here for a modified use http://www.vbaexpress.com/forum/show...newpost&t=1466)
the excel process is left running when the userform is closed. The Excel application is not visible while the Word Userform is open, unless it was visible perviously. The code I'm attempting to use is as follows:
[VBA]
Private Sub UserForm_Terminate()
Dim Datafile As String, DataRoute As String, MyXL As Object
DataRoute = MyPath.Text & MyFile.Text
Datafile = MyFile.Text
If Tasks.Exists("Microsoft Excel - " & Datafile) = True Then
Set MyXL = GetObject(DataRoute)
End If
On Error Resume Next
MyXL.Windows(Datafile).Close False
Set MyXL = Nothing
End Sub
[/VBA]
I've also tried variations on this, but without success.
MD
MVP (Excel 2008-2010)
Post a workbook with sample data and layout if you want a quicker solution.
To help indent your macros try Smart Indent
Please remember to mark threads 'Solved'
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules