ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   reference to FileSystemObject (https://www.excelbanter.com/excel-programming/381247-reference-filesystemobject.html)

Allen_N

reference to FileSystemObject
 
Excel VBA on my work PC throws errors when I try to refer to the class
'FileSystemObject' or its associated constants (such as 'WindowsFolder').

Which library is the one I need a reference to?

Thanks!

NickHK

reference to FileSystemObject
 
Assuming scripting is not disabled, you need add a reference
(ToolsReferences) to "Microsoft Scripting Runtime".

NickHK

"Allen_N" wrote in message
...
Excel VBA on my work PC throws errors when I try to refer to the class
'FileSystemObject' or its associated constants (such as 'WindowsFolder').

Which library is the one I need a reference to?

Thanks!




Peter T

reference to FileSystemObject
 
Just to add, without the reference you could use late binding but subject to
scripting not disabled as Nick mentioned. You would need to declare all
related object variables "As Object" and use numeric values instead of named
constants and would loose intellisence, eg

Sub test()
Dim oFSO As Object

On Error GoTo errH
Set oFSO = CreateObject("Scripting.FileSystemObject")
For i = 0 To 2
Debug.Print oFSO.GetSpecialFolder(i)
Next
Exit Sub

errH:
MsgBox Err.Description
End Sub

Regards,
Peter T

"NickHK" wrote in message
...
Assuming scripting is not disabled, you need add a reference
(ToolsReferences) to "Microsoft Scripting Runtime".

NickHK

"Allen_N" wrote in message
...
Excel VBA on my work PC throws errors when I try to refer to the class
'FileSystemObject' or its associated constants (such as

'WindowsFolder').

Which library is the one I need a reference to?

Thanks!







All times are GMT +1. The time now is 09:57 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com