Check Excel Sheet Open

IanT

Registered User.
Local time
Today, 01:20
Joined
Nov 30, 2001
Messages
191
Hi
I am using the code below to check if a Excel workbook is open or not. The problem is that it does not close the workbook correctly, can anyone advise me why yhis is happening!

Function ExcelDocTest()

Dim xlApp As Excel.Application
Dim Wbk As Excel.Workbook
Dim BolYN As Boolean

Set xlApp = CreateObject("excel.application")

xlApp.Visible = No

Set Wbk = xlApp.Workbooks.Open("\\server1\shared data\Statistics\Member Data\Home Spend\2004 DSA\Home Data.xls")

BolYN = Wbk.ReadOnly

Select Case BolYN
Case True
MsgBox "Home Spend.xls Workbook Open Cannot Run DSA Report"

Case False

MsgBox "Workbook close"


End Select

Wbk.Close

xlApp.Quit
Set xlApp = Nothing


End Function
 

Users who are viewing this thread

Back
Top Bottom