VBA learner ITG
Active Member
- Joined
- Apr 18, 2017
- Messages
- 272
- Office Version
- 365
- Platform
- Windows
- MacOS
Hi all,
I need your advice if possible for some reason I keep getting this error message appearing only on 1 specific macro workbook where it says:
I have the following selected in the reference library and cant understand the cause of the issue!
My Code below for Reference:
I need your advice if possible for some reason I keep getting this error message appearing only on 1 specific macro workbook where it says:
Compile Error:
Cant Find Project or Library
I have the following selected in the reference library and cant understand the cause of the issue!
My Code below for Reference:
VBA Code:
Sub Get_Files_test()
Dim objFSO As Object
Dim objFolder As Object
Dim objFile As Object
Dim i As Integer
Dim zFilepath As String
Dim MyRow As Integer
MyRow = InputBox("What Row to start at?")
'Create an instance of the FileSystemObject
Set objFSO = CreateObject("Scripting.FileSystemObject")
'Get the folder object
With Application.FileDialog(msoFileDialogFolderPicker)
.AllowMultiSelect = False
If .Show = False Then Exit Sub
zFilepath = .SelectedItems(1)
DoEvents
End With
Sheets("Control").Range("E2").Value = zFilepath & "\"
Set objFolder = objFSO.GetFolder(zFilepath)
i = MyRow
'loops through each file in the directory and prints their names and path
For Each objFile In objFolder.Files
'print file name
Cells(i, 4) = objFile.Name
'print file path
Cells(i, 5) = objFile.Path
i = i + 1
Next objFile
End Sub