Results 1 to 4 of 4
  1. #1
    Star Lounger
    Join Date
    Apr 2002
    Location
    Sydney, New South Wales, Australia
    Posts
    86
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Is file open locally (excel97)

    I would like to be able to determine if a file is open on the users machine

    if the file is open locally then switch to that file using Windows(strFileName).Activate

  2. #2
    Star Lounger
    Join Date
    Apr 2002
    Location
    Sydney, New South Wales, Australia
    Posts
    86
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Is file open locally (excel97)

    Thank you Hans

    I used it as a function that returned a true or false
    on true I used windows(strFile).activate
    on false it did other stuff

    but I received the following
    " Compile Error
    Invalid Next Control variable reference"

    I removed the "i" from after Next and everything appears to be working perfectly

  3. #3
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Is file open locally (excel97)

    Sorry, it should have been Next wbk, or just Next as you discovered.

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Is file open locally (excel97)

    Edited by HansV. The code originally had Next i which is plainly wrong.

    Try this procedure:

    Sub TestOpen(strFilename As String)
    Dim wbk As Workbook
    For Each wbk In Workbooks
    If wbk.FullName = strFilename Then
    wbk.Activate
    Exit For
    End If
    Next wbk
    End Sub

    Use it like this:

    TestOpen "C:ExcelMyWorkbook.xls"

Posting Permissions

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