Popping up message box with "Make Sure the Specified folder Ex
The problem related to the opening large no of excel files and in between it
pops up a message box which need to be avoided while running the macros even
after using Displayalerts = false. This pop up comes up only when no of files
are more than 250.
"NickHK" wrote:
For the record, what was the cause of the error ?
NickHK
"Rajesh T S" wrote in message
...
Thanks for information and all the support NICK and TOM .
Thanks for all the help
"NickHK" wrote:
Well, you only open then close the WB so that is not a concern.
And VBA can handle more than a 300 strings in an array.
NickHK
"Rajesh T S"
...
Hi NICK / TOM
Is there any restrictions on No of files that need to be processed
something
like only some no of file handlers were allowed at a time ?
Thanks
Rajesh
"NickHK" wrote:
Strip down your code to something like that below, to check whether
the
problem really is something to do with filename:
Private Sub CommandButton1_Click()
Call ReadMainIPLuxembourg
End Sub
Public Sub ReadMainIPLuxembourg()
Dim FPathArray() As String
Dim FOLDER_PATH As String
Dim i As Long
Dim SourceWb As Workbook
FOLDER_PATH = "C:\Excel Test\"
FPathArray = ReadFiles(FOLDER_PATH)
For i = 0 To UBound(FPathArray())
Worksheets(1).Range("A1").Offset(i, 0).Value = FPathArray(i)
Set SourceWb = Workbooks.Open(FPathArray(i))
With SourceWb
Debug.Print .Name
.Close False
End With
Next
End Sub
NickHK
"Rajesh T S" wrote in message
...
Hi Nick,
Find below the code for ReadFiles procedure. I assume that the
length
of
file name does not exceed the MAX_PATH, since i'll be using the
local
machine.
---------------------------------
Public Function ReadFiles(ByVal FolderPath As String) As String()
Dim FileCount As Integer
Dim Files As String
Dim FileArray() As String
Dim FilePathArray() As String
FileCount = 0
Files = Dir(FolderPath & "*.xls")
ReDim Preserve FilePathArray(0)
While Files < ""
ReDim Preserve FileArray(0 To FileCount)
ReDim Preserve FilePathArray(0 To FileCount)
FileArray(FileCount) = Files
FilePathArray(FileCount) = FolderPath & Files
FileCount = FileCount + 1
Files = Dir()
Wend
ReadFiles = FilePathArray
End Function
---------------------------------
"NickHK" wrote:
Hard to say much as you did not include the important ReadFiles
routine.
Any chance you have some file names with Unicode characters in
them ?
Does the length of the path + filename exceed MAX_PATH (260
characters)
?
NickHK
"Rajesh T S" wrote in
message
...
Hi Tom.
thanks for the response
I can assure you that the array will have valid file names that
we
have
read. Find below the whole code for your information. have a
walk
through
and
let me know if any instance of possible error
-------------------------------------------------------------------
Public Sub ReadMainIPLuxembourg()
Dim IsFileDeleted As Boolean
Dim FPathArray() As String
Dim IsValid As Boolean
Dim Proceed As Boolean
Dim sRows As Integer
Dim sColumns As Integer
Dim CellNum As Integer
Dim FilePath As String
Dim FundRange As Range
Dim RowCount As Integer
Dim FOLDER_PATH As String
Dim strFundName As String
If Trim$(strDataSourcePath) = "" Then Exit Sub
FOLDER_PATH = strDataSourcePath & "\Luxembourg\" --
Source
folder
FPathArray = ReadFiles(FOLDER_PATH) -- Reading all the
file(s)
into
the array.
If (FPathArray(0) < "") Then
Set TargetWb = Workbooks.Open(ThisWorkbook.Path &
"\Template.xls",
False, False) -- OPening the target file to
---- CUT --------------
|