Obscure VBA Syntax

P

Peter Hewett

Hi All

I'm using the Scripting FileSystemObject. There's an Enum called
"FileAttribute" and has the following members:

Alias, Archive, Compressed, Directory, Hidden, Normal, ReadOnly, System,
Volume.

Being an Enum, you can do the usual stuff like:

Dim faAttributes As Scripting.FileAttribute
faAttributes = Archive Or Hidden Or ReadOnly

Now who knows how to refer to the system member of the FileAttribute Enum????

I know how to kludge around it but what's the correct syntax, since you can't
use:
faAttributes = System

Thanks in advance + Cheers - Peter
 
J

Jezebel

The short answer is: use '4'. (The ObjectBrowser lists the values.) It's
interesting that these enum values don't work like others in VB/VBA. Usually
you can bypass ambiguous naming by qualifying it with the class and enum
name (word.WdWindowState.wdWindowStateMaximize) ... but -- as I guess you
discovered -- it doesn't work in this case.

A lot of serious VB users have long decried the use of the Scripting object
entirely.
 
P

Peter Hewett

Hi Jezebel

Yeah, you're right I tried name qualification and found that didn't work! I
understand about the ObjectBrowser <g> I was poking around last night and
the FileAttribute Enum and ObjectBrowser reckons the members belong to:
"Scripting.__MIDL___MIDL_itf_scrrun_0000_0001"!!!

I guess I'm not too serious. I quite like the FSO, it nicely bridges
Dir/GetAttr or Application.FileSearch and API functionality.

Thanks + Cheers - Peter
 
J

Jezebel

I wondered about Scripting.__MIDL___MIDL_itf_scrrun_0000_0001 too. Google's
never heard of it.

And I agree about the FSO -- I've never had any problems with it either;
although there is a risk if you're distributing code that uses it: Norton
advises people to disable it, although I've never met anyone who does.
 

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