Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 28
Default Problems closing Excel correctly by code

Dear All,

W2000
Office2000

Access-application that manages quotations (= excel-files)

In a sub I change some values in an excel-file and close like this (see
code-end below)
.......
xlApp.Visible = False
........
Set WS = Nothing
WB.Close SaveChanges:=True
Set WB = Nothing
xlApp.Quit
Set xlApp = Nothing
Exit sub

This workes OK, BUT while re-opening this file or another I test if Excel is
running to prevent that several quotations are open at the same time.
Although there is no excel-file active the function IsExcelRunningNow()
returns TRUE

Where is the mistake?

THANKSł,

Filip

Function IsExcelRunningNow() As Boolean

Dim MyXL As Object ' Variable to hold reference to Microsoft Excel.
On Error Resume Next ' Defer error trapping.
IsExcelRunningNow = True
Set MyXL = GetObject(, "Excel.Application")
If Err.Number < 0 Then IsExcelRunningNow = False
Err.Clear ' Clear Err object in case error occurred.
Set MyXL = Nothing ' Release reference to the application and
spreadsheet.

End Function


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 233
Default Problems closing Excel correctly by code

Pls check if excel is running in the background invisibly.

Use MyXL.UserControl = false before you quit

BTW read up on the GetObject, since with excel allows the following:

Dim wb as Object

Set wb = Getobject("c:\Myfile.xls")

you could directly test if a quotation is open by connect to that
quotation.

Dm Unseen

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 28
Default Problems closing Excel correctly by code

Thanks,

BUT no change

Finally the problem was soved by changing my code ActiveSheet WS

WS.Unprotect (varPassWord)
WS.Cells(2, 2) = "Basisofferte" & "=" & strBasisNaam
WS.Protect (varPassWord)

Thanks

"DM Unseen" wrote in message
oups.com...
Pls check if excel is running in the background invisibly.

Use MyXL.UserControl = false before you quit

BTW read up on the GetObject, since with excel allows the following:

Dim wb as Object

Set wb = Getobject("c:\Myfile.xls")

you could directly test if a quotation is open by connect to that
quotation.

Dm Unseen



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
Problems merging an excel file due to code or file problems? Cindy M -WordMVP- Excel Programming 0 September 14th 04 02:58 PM
problems closing excel Filips Benoit Excel Programming 2 August 21st 04 12:31 PM
Problems closing a workbook with VBA N E Body[_2_] Excel Programming 3 July 2nd 04 02:24 PM
problems closing workbook Kevin Excel Programming 2 December 17th 03 08:26 AM
Excel code to Wait until Word finishes printing before closing Mike Molyneaux[_2_] Excel Programming 2 October 24th 03 02:45 AM


All times are GMT +1. The time now is 08:16 AM.

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"