Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 58
Default Closing Excel in VBA leaves it in task list

I have some VBA written that opens a word document and closes the spreadsheet. It seems to work fine, but when I reopen the spreadsheet the page does not display (it is transparent, other than the boarder). I am able to close the Excel window. I look into the task list and there is an EXCEL process still running. I kill that and then the spreadsheet is able to open again.

Below is the language that I am using on a Click event:

//CODE
Private Sub openMerge_Click()
Dim x As Object, y As Object, z As String
On Error Resume Next
Set x = GetObject(, "Word.Application")



If Err.Number = 429 Then
Set x = CreateObject("Word.Application")
End If

z = "F:\FIS\TRAVEL\Excel Driven Travel Form\Local Travel.doc"
x.Visible = True
x.Activate

Set y = x.Documents(z)

If y Is Nothing Then
Set y = x.Documents.Open(z)
End If

Application.DisplayAlerts = False
ActiveWorkbook.Close
Application.DisplayAlerts = True
Application.Quit

On Error GoTo 0
End Sub
//END CODE

Any help would be greatly appreciated.

-Brandon

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Closing Excel in VBA leaves it in task list

you have references to the word document - as long as they exist, so will
Excel. You need to release all references to word and then close Excel

//CODE
Private Sub openMerge_Click()
Dim x As Object, y As Object, z As String
On Error Resume Next
Set x = GetObject(, "Word.Application")



If Err.Number = 429 Then
Set x = CreateObject("Word.Application")
End If

z = "F:\FIS\TRAVEL\Excel Driven Travel Form\Local Travel.doc"
x.Visible = True
x.Activate

Set y = x.Documents(z)

If y Is Nothing Then
Set y = x.Documents.Open(z)
End If


set y = nothing
set x = nothing

Application.DisplayAlerts = False

if ActiveWorkbook.Name < Thisworkbook.Name then _
ActiveWorkbook.Close SaveChanges:=False
Application.DisplayAlerts = True

ThisWorkbook.Saved = True
Application.Quit

On Error GoTo 0
End Sub
//END CODE




--
Regards,
Tom Ogilvy

"Brandon" wrote in message
...
I have some VBA written that opens a word document and closes the

spreadsheet. It seems to work fine, but when I reopen the spreadsheet the
page does not display (it is transparent, other than the boarder). I am able
to close the Excel window. I look into the task list and there is an EXCEL
process still running. I kill that and then the spreadsheet is able to open
again.

Below is the language that I am using on a Click event:

//CODE
Private Sub openMerge_Click()
Dim x As Object, y As Object, z As String
On Error Resume Next
Set x = GetObject(, "Word.Application")



If Err.Number = 429 Then
Set x = CreateObject("Word.Application")
End If

z = "F:\FIS\TRAVEL\Excel Driven Travel Form\Local Travel.doc"
x.Visible = True
x.Activate

Set y = x.Documents(z)

If y Is Nothing Then
Set y = x.Documents.Open(z)
End If

Application.DisplayAlerts = False
ActiveWorkbook.Close
Application.DisplayAlerts = True
Application.Quit

On Error GoTo 0
End Sub
//END CODE

Any help would be greatly appreciated.

-Brandon



Reply
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
sync between table in excel to task list in outlook ayelet Excel Discussion (Misc queries) 0 August 31st 08 06:19 AM
Importing From Excel to Task List Wilbur Excel Discussion (Misc queries) 1 July 17th 07 03:12 PM
Excel still running in task manager after closing the application Willem Excel Discussion (Misc queries) 0 December 5th 06 01:56 PM
create and expand/collapse todo list under a task in excel flamingo1 Excel Discussion (Misc queries) 2 July 12th 06 05:00 PM
Printing leaves EXCEL.EXE process in Task Manager eeidfn Excel Discussion (Misc queries) 1 February 28th 06 02:24 AM


All times are GMT +1. The time now is 03:57 PM.

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

About Us

"It's about Microsoft Excel"