Tejas Kore
Board Regular
- Joined
- Nov 2, 2017
- Messages
- 72
- Office Version
- 365
- Platform
- Windows
Hi Friends,
I am using below FSO object because of my requirements. Because of this every time I run the code , I have to go to Menu Bar , select Tools --> References --> Microsoft Scripting Runtime and check it.
But it stays checked till the VB Editor is open .Once the editor is closed , I have to repeat the whole process again before running the program.
I wanted to know is there any way by which we can permanantly check the above said option ?
Public FSO As New FileSystemObject
Function listfiles(ByVal sPath As String)
Dim vaArray As Variant
Dim i As Integer
Dim oFile As Object
Dim oFSO As Object
Dim oFolder As Object
Dim oFiles As Object
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oFolder = oFSO.GetFolder(sPath)
Set oFiles = oFolder.Files
ReDim vaArray(1 To oFiles.Count)
i = 1
For Each oFile In oFiles
vaArray(i) = oFile.Name
i = i + 1
Next
listfiles = vaArray
End Function
I am using below FSO object because of my requirements. Because of this every time I run the code , I have to go to Menu Bar , select Tools --> References --> Microsoft Scripting Runtime and check it.
But it stays checked till the VB Editor is open .Once the editor is closed , I have to repeat the whole process again before running the program.
I wanted to know is there any way by which we can permanantly check the above said option ?
Public FSO As New FileSystemObject
Function listfiles(ByVal sPath As String)
Dim vaArray As Variant
Dim i As Integer
Dim oFile As Object
Dim oFSO As Object
Dim oFolder As Object
Dim oFiles As Object
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oFolder = oFSO.GetFolder(sPath)
Set oFiles = oFolder.Files
ReDim vaArray(1 To oFiles.Count)
i = 1
For Each oFile In oFiles
vaArray(i) = oFile.Name
i = i + 1
Next
listfiles = vaArray
End Function