Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
How could I close a workbook in a case of an error or if it was opened by a
program and wasn't closed when I start the program again? (I have many workbooks to be opened and closed.) I'm opening a workbook as follows: Dim xlapp As New Excel.Application Set xlbook = xlapp.Workbooks.Open(strOurFileName, True) logFlagApp = True ' setting a flag that it was opened .... '********** In addition I'm checking whether it's opened by using the following: Function FileLocked(strFileName As String) As Boolean On Error Resume Next Open strFileName For Binary Access Read Lock Read As #1 Close #1 If Err.Number < 0 Then FileLocked = True Err.Clear End If End Function '********************* ..... ErrorHandling_Err: If Err Then If logFlagApp = False Then Else xlapp.ActiveWorkbook.Save xlapp.Quit logFlagApp = False End If Else Resume ErrorHandling_Exit End If When the program opened the workbook and didn't close it I'm trying to use this by inserting it into the code during debugging: Excel.ActiveWorkbook.Close but it's not working. There is some mistake about an object. Somehow it was working before. Thanks, Alex |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Opened Autosave but when closing workbook Autosave closes itself | Excel Worksheet Functions | |||
Opening a workbook if not opened, going to it if already opened | Excel Programming | |||
Opening a workbook if not opened, going to it if already opened | Excel Programming | |||
Opening a workbook if not opened, going to it if already opened | Excel Programming | |||
How to see if the opened workbook is opened by another user ? | Excel Programming |