Reputation: 401
I'm tying to get this code to work and for some reason, I can't assign any of DriveTypeConst. The compiler just says "Menthod or Data Member not found"
Dim objFSO As FileSystemObject
Dim objDrv As Drive
Dim enumDrvType As Scripting.DriveTypeConst
Dim enumRemoteDrvType As Long
Set enumRemoteDrvType = Scripting.DriveTypeConst.Remote -- Error here
Set objFSO = New FileSystemObject
I know I have the Microsoft Scripting Runtime referenced, so I'm not entirely sure why I can't access this. I'm using Access 2010.
Upvotes: 1
Views: 134
Reputation: 22205
The TypeLib of the Scripting
enumerations is a little messed up, as you can see in the Object Browser:
The issue isn't that you can't explicitly specify the namespace of Remote
- it's that Remote
isn't in the Scripting.DriveTypeConst
namespace. If you really want/need to you can explicitly declare it like this:
Sub Example()
Dim x As Scripting.DriveTypeConst
x = Scripting.[__MIDL___MIDL_itf_scrrun_0001_0000_0001].Remote
Debug.Print x
End Sub
But, as @TimWilliams points out, enumerations are given global scope in VBA so you only need to fully qualify them if you have something declared in a more local scope with the same name (i.e., if you had a variable in your procedure named Remote
).
Upvotes: 3
Reputation: 166860
This will work:
enumRemoteDrvType = Remote
You should get intellisense as you're typing the enum
Upvotes: 2