Hallo! na een tijd geprobeerd te hebben een excel document te kraken voor mijn college, ben ik in de VBA Code's gekomen. Mijn collega zegt dat hij niet in dusverre zoveel verstand van macro's heft dat hij dit kan begrijpen. Zou iemand mij kunnen helpen de code te begrijpen (Stap voor stap uit te leggen wat er gebeurd.)? Excel geeft een "error 445" kijken naar het stukje code dat is aangegeven met "*****"
Hartelijk dank!
CODE:
Sub look()
Set Data = ActiveWorkbook.Worksheets("Update")
***** Set fs = Application.FileSearch *****
Dim j As String
With fs ' looks in Folder "Update Files" files for excel files and lists them
.LookIn = ThisWorkbook.Path & "\Update Files" ' on sheet Update in cells BJ1 and following
.Filename = "*.xls"
If .Execute > 0 Then
For i = 1 To .FoundFiles.Count
Data.Activate
Cells(i, 62) = .FoundFiles(i)
Next i
Else
MsgBox "No Microsoft Excel files found." 'if folder is empty
End If
End With
End Sub
Sub look2() 'works like look
Set Data = ActiveWorkbook.Worksheets("Parameters")
Set fs = Application.FileSearch
Dim j As String
With fs
.LookIn = ThisWorkbook.Path & "\PC&L DB'S"
.Filename = "*.xls"
If .Execute > 0 Then
For i = 1 To .FoundFiles.Count
Data.Activate
Cells(i, 62) = .FoundFiles(i)
Next i
Else
MsgBox "No Microsoft Excel files found."
End If
End With
End Sub
Sub look3() 'works like look
Set Data = ActiveWorkbook.Worksheets("Output Inventory Segmentation")
Set fs = Application.FileSearch
Dim j As String
With fs
.LookIn = ThisWorkbook.Path & "\Inventory Segmentation Tool"
.Filename = "*.xls"
If .Execute > 0 Then
For i = 1 To .FoundFiles.Count
Data.Activate
Cells(i, 62) = .FoundFiles(i)
Next i
Else
MsgBox "No Microsoft Excel files found."
End If
End With
End Sub
Sub look4() 'works like look
Set Data = ActiveWorkbook.Worksheets("Update")
Set fs = Application.FileSearch
Dim j As String
With fs
.LookIn = ThisWorkbook.Path & "\Acquisition Tool"
.Filename = "*.xls"
If .Execute > 0 Then
For i = 1 To .FoundFiles.Count
Data.Activate
Cells(i, 62) = .FoundFiles(i)
Next i
Else
MsgBox "No Microsoft Excel files found."
End If
End With
End Sub
Hartelijk dank!
CODE:
Sub look()
Set Data = ActiveWorkbook.Worksheets("Update")
***** Set fs = Application.FileSearch *****
Dim j As String
With fs ' looks in Folder "Update Files" files for excel files and lists them
.LookIn = ThisWorkbook.Path & "\Update Files" ' on sheet Update in cells BJ1 and following
.Filename = "*.xls"
If .Execute > 0 Then
For i = 1 To .FoundFiles.Count
Data.Activate
Cells(i, 62) = .FoundFiles(i)
Next i
Else
MsgBox "No Microsoft Excel files found." 'if folder is empty
End If
End With
End Sub
Sub look2() 'works like look
Set Data = ActiveWorkbook.Worksheets("Parameters")
Set fs = Application.FileSearch
Dim j As String
With fs
.LookIn = ThisWorkbook.Path & "\PC&L DB'S"
.Filename = "*.xls"
If .Execute > 0 Then
For i = 1 To .FoundFiles.Count
Data.Activate
Cells(i, 62) = .FoundFiles(i)
Next i
Else
MsgBox "No Microsoft Excel files found."
End If
End With
End Sub
Sub look3() 'works like look
Set Data = ActiveWorkbook.Worksheets("Output Inventory Segmentation")
Set fs = Application.FileSearch
Dim j As String
With fs
.LookIn = ThisWorkbook.Path & "\Inventory Segmentation Tool"
.Filename = "*.xls"
If .Execute > 0 Then
For i = 1 To .FoundFiles.Count
Data.Activate
Cells(i, 62) = .FoundFiles(i)
Next i
Else
MsgBox "No Microsoft Excel files found."
End If
End With
End Sub
Sub look4() 'works like look
Set Data = ActiveWorkbook.Worksheets("Update")
Set fs = Application.FileSearch
Dim j As String
With fs
.LookIn = ThisWorkbook.Path & "\Acquisition Tool"
.Filename = "*.xls"
If .Execute > 0 Then
For i = 1 To .FoundFiles.Count
Data.Activate
Cells(i, 62) = .FoundFiles(i)
Next i
Else
MsgBox "No Microsoft Excel files found."
End If
End With
End Sub