Logo 
Search:

MS Office Forum

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds

How to know state of opened or Closed File in Excel

  Asked By: Juana    Date: Aug 26    Category: MS Office    Views: 785
  

If i wnt to know whether the file in excel is open or close then how v can know
?

Means when i m closing any excel workbook then at that time if it is accidently
colsed then it is generating exception. So before that i wnt to check whether
the file is open or not.

Code for closing file.

excelall.activeworkbook.close(SaveChanges:=false)
excelall.quit()

If any one know then tell me how to check status of the excel file?

Share: 

 

2 Answers Found

 
Answer #1    Answered By: Djoser Massri     Answered On: Aug 26

If you search ie Google for "FileAlreadyOpen" you'll find some usefull codes!

 
Answer #2    Answered By: Sherrie Thomas     Answered On: Aug 26

Microsoft's own solution:

Function IsOpen(FileName As String) As Boolean
Dim wb As Workbook
For Each wb In Application.Workbooks
If UCase(wb.Name) = UCase(FileName) Then
IsOpen = True
Exit Function
End If
Next wb
IsOpen = False
End Function

 
Didn't find what you were looking for? Find more on How to know state of opened or Closed File in Excel Or get search suggestion and latest updates.




Tagged: