Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / March 2006

Tip: Looking for answers? Try searching our database.

How to skip files which are open?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Jan Nademlejnsky - 22 Mar 2006 03:41 GMT
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
Jim Cone - 22 Mar 2006 04:41 GMT
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" <jannade@shaw.ca> 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
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.