+ Reply to Thread
Results 1 to 2 of 2

How to skip files which are open?

  1. #1
    Jan Nademlejnsky
    Guest

    How to skip files which are open?

    I run update macro loop to process about 50 spreadsheets, but sheets could
    be used (open) by somebody. I need to skip processing of the sheet if it is
    open. Something like this:

    For R = 1 to 50
    If FileR is open then goto Skip '<======This is what I need
    Open_sheet
    Update_it
    Save_and_Close_it
    Skip:
    Next R

    Thanks for your help

    Jan



  2. #2
    Jim Cone
    Guest

    Re: How to skip files which are open?

    Jan,
    Something like the following...
    Jim Cone
    San Francisco, USA
    http://www.realezsites.com/bus/primitivesoftware

    '----------------------
    Sub OpenClosedFilesOnly()
    Dim R
    For R = 1 To 50
    If Not IsItOpen(FileR) Then
    Open_sheet
    Update_it
    Save_and_Close_it
    End If
    Skip:
    Next R
    End Sub

    ' Returns True or False.
    '------------------
    Function IsItOpen(ByRef BookName As String) As Boolean
    Dim WB As Workbook
    On Error Resume Next
    Set WB = Workbooks(BookName)
    IsItOpen = (Err.Number = 0)
    Set WB = Nothing
    End Function
    '------------------------------------------------


    "Jan Nademlejnsky" <[email protected]> wrote in message
    I run update macro loop to process about 50 spreadsheets, but sheets could
    be used (open) by somebody. I need to skip processing of the sheet if it is
    open. Something like this:

    For R = 1 to 50
    If FileR is open then goto Skip '<======This is what I need
    Open_sheet
    Update_it
    Save_and_Close_it
    Skip:
    Next R

    Thanks for your help
    Jan



+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1