LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 84
Default Problem opening Workbook files in Macro

I am learning how to work with opening excel workbook files. I am getting a
run-time error 9, supscript out of range. I know what that means but I don't
see why I am getting that error.

There are 6 files in the directory and I am only processing 0-5 which is six.

Please comment.
' Fill the array (myFiles) with the list of Excel files in the folder
NumFiles = 0
Do While FilesInPath < ""
' Dynamically size MyFiles based on number of files
ReDim Preserve MyFiles(0 To NumFiles)
MyFiles(NumFiles) = FilesInPath
FilesInPath = Dir()
NumFiles = NumFiles + 1
Loop

' Loop through the files to process them
NumDone = 0

Do While (NumDone <= NumFiles)
' Subscript error at -
- Set MyBook = Workbooks.Open(MyPath & MyFiles(NumDone))
MsgBox NumDone
MyBook.Close savechanges:=False
NumDone = NumDone + 1
Loop

To process files that are in a folder, do you have to open them?

Thanks

 
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
Excel Problem opening files atharsagri Excel Discussion (Misc queries) 7 April 9th 09 07:13 AM
Problem opening excel files Scandy New Users to Excel 1 August 4th 08 10:01 PM
Problem opening files from server [email protected] New Users to Excel 1 January 8th 08 02:50 AM
Problem Opening Files Pedr Llwyd Excel Discussion (Misc queries) 2 August 29th 05 04:13 PM
excel VBA problem - setting workbook as variable & opening/re-opening safe Excel Programming 1 August 20th 04 12:22 AM


All times are GMT +1. The time now is 09:41 AM.

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

About Us

"It's about Microsoft Excel"