reference to FileSystemObject

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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!
 
Assuming scripting is not disabled, you need add a reference
(Tools>References) to "Microsoft Scripting Runtime".

NickHK
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top