Results 1 to 2 of 2
  1. #1
    Join Date
    Nov 2004
    Posts
    32

    Unanswered: Detecting file Open status

    I need to detect if a particular Excel file is currently open useing VBA. Can anyone help as to which property to reference???

  2. #2
    Join Date
    Feb 2004
    Posts
    533
    I use this function.
    You'd might call it Like this:

    If WorkbookIsOpen("somebook.xls") Then
    Workbooks("somebook.xls").Activate
    Else
    Workbooks.Open FileName:="c:/My Documents/somebook.xls", _
    ReadOnly:=False, Notify:=False
    End If


    Code:
    '
    Function WorkbookIsOpen(wbname) As Boolean
    '   Returns TRUE if the workbook is open
        Dim x As Workbook
        On Error Resume Next
        Set x = Workbooks(wbname)
        If Err = 0 Then WorkbookIsOpen = True _
            Else WorkbookIsOpen = False
    End Function
    ~

    Bill

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •