Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,290
Default 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" 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
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to change default Open/Files of Type to "Microsoft Excel Files Tammy Excel Discussion (Misc queries) 2 January 14th 08 11:06 PM
Macro to open *.dat files and save as .txt (comma delimited text files) [email protected] Excel Programming 2 November 30th 05 05:50 AM
Open files, skip a folder Steph[_3_] Excel Programming 7 July 14th 05 10:09 PM
file open via IE hyperlink causes already open files to shrink and tile Marc Setting up and Configuration of Excel 0 May 4th 05 08:13 PM
Open files in folder - skip if already open Steph[_3_] Excel Programming 6 March 25th 05 06:49 PM


All times are GMT +1. The time now is 10:51 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"