Help converting code to late binding

G

Guest

I am using Office 2003 on Windows XP.

I am trying to convert the following to late binding, but I get an error
"...cannot create object..." at the line indicated. I'm sure it is a syntax
error, but I don't know what the correct syntax would be. Can someone help me
out and post a correction?

Dim oFSO As Object
Dim oDrives As Object
Dim oDrive As Object
Dim strLetter As String
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oDrives = CreateObject("Scripting.Drives") < ERROR
Set oDrive = CreateObject("Scripting.Drive") < ERROR

Thanks much in advance for your assistance!
 
T

Tom Ogilvy

Once you get the reference to the oFSO, then you have access to that object
model:

Sub f()
Dim oFSO As Object
Dim oDrives As Object
Dim oDrive As Object
Dim strLetter As String
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oDrives = oFSO.Drives
For Each oDrive In oDrives
Debug.Print oDrive.DriveLetter
Next
End Sub
 
G

Guest

Thanks Tom!

Tom Ogilvy said:
Once you get the reference to the oFSO, then you have access to that object
model:

Sub f()
Dim oFSO As Object
Dim oDrives As Object
Dim oDrive As Object
Dim strLetter As String
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oDrives = oFSO.Drives
For Each oDrive In oDrives
Debug.Print oDrive.DriveLetter
Next
End Sub
 

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

Top