Below is the code, I am not too understand code, check online and excel does not let use Application. FileSearch,
. So how can I put the Application FileSearch instead, seek expert advice, more detailed, the better, I am a novice,
Thank you!!!!
Private Sub CommandButton1_Click ()
Dim fileName As String
Dim kenSaKuFlg As String
Dim strKey As String
Dim oFileSearch As Object
Dim w_strTemp As String
Dim the book As the String
Dim rowNum As Integer
Dim sFileAllName As String
Dim sName () As String
Dim maxRowNum As Integer
Dim sFilePath As String
Dim sNum As String
Dim bugs As String
Dim NewXlApp As Excel. Application
Dim num As Integer
SFilePath=Trim (TextBox1. Text)
The Set oFileSearch=Application. FileSearch
If sFilePath="" Then
MsgBox "検 cable フ ォ ル ダ を し into force て く だ さ い,"
The Exit Sub
End the If
With oFileSearch
. NewSearch
The FileType=msoFileTypeAllFiles' full て type の フ ァ イ ル,
.=sFilePath 'LookIn フ ァ イ ル タ を specified す る,
The fileName="*. XLS" 'フ ァ イ ル を specified す る,
. SearchSubFolders=False
. The Execute
'フ ァ イ ル を exist す る,
For I=1 To. FoundFiles. Count
Num=0
The Set NewXlApp=New Excel. Application
SFileAllName=. FoundFiles (I)
SName=Split (FoundFiles (I), "")
SFileName=sName (UBound (sName))
NewXlApp. Workbooks. Open sFileAllName
SNum=NewXlApp. Sheets (1). The Range (" K6 "). The Value
Bug=NewXlApp. Sheets (1). The Range (" O18 "). The Value
A1=NewXlApp. Sheets (1). The Range (" O19 "). The Value
A2=NewXlApp. Sheets (1). The Range (" N27 "). The Value
NewXlApp. Quit
The Set NewXlApp=Nothing
Cells (I + 1, 8)=sFileName
Cells (I + 1, 9)=sNum
Cells (I + 1, 10)=bug
Cells (I + 1, 11)=a1
Cells (I + 1, 12)=a2
Next
End With
MsgBox "処 Richard が end し ま す, confirm し て く だ さ い,"
End Sub
CodePudding user response:
I think I out...My computer is 2003 + 2007
CodePudding user response:
Office 2007 doesn't support this,However, see you used to. SearchSubFolders=False, that is very well done,
Don't have to search subdirectories, good processing, can write a simple function, to replace it,
Private Function SearchFiles (sPath As String, sFileName As String) As a String ()
Dim aList () As String
Dim sTemp As String
Dim i& K& , U As Long
If (Right $(sPath, 1)="") Then
STemp=sPath & amp; SFileName
The Else
STemp=sPath & amp; "" & amp; SFileName
End the If
K=1: U=31
ReDim aList (U)
STemp=Dir $(sTemp, 7 & amp;)
Do
If (Len (sTemp)=0) Then Exit the Do
K=k + 1
If (k & gt; U) Then
U=U + 8
ReDim Preserve aList (U)
End the If
AList (k)=sTemp
STemp=Dir $()
Loop
If (k & gt;=0) Then ReDim Preserve aList (k)
SearchFiles aList of=
End the Function
'application example:
Private Sub test ()
Dim aFiles () As String
Dim i&
'search "D: " document of all the.xls files:
AFiles=SearchFiles (" D: \ document ", "*. XLS")
For I=0 To UBound (aFiles)
The Debug. Print I, aFiles (I)
Next
End Sub
CodePudding user response:
If you can search the filesearch deprecated, that should see you can use the application. The alternative findfile method,Actually two functions are the same, is to open the specified file, and return to an application variable,
CodePudding user response:
Studied the