HaimD
asked on
Finding a Hidden File in Excel VBA
I have this line of code in Excel's VBA:
x = Len(Dir$(varFileName))
Unfortunately, x = 0 if the file's attributes (i.e., varFileName) are set to hidden. How can I keep the file hidden, yet get the true value for x?
x = Len(Dir$(varFileName))
Unfortunately, x = 0 if the file's attributes (i.e., varFileName) are set to hidden. How can I keep the file hidden, yet get the true value for x?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You're welcome.
From VBA Help, the attributes you can use for Dir$
Constant Value Description
vbNormal 0 (Default) Specifies files with no attributes.
vbReadOnly 1 Specifies read-only files in addition to files with no attributes.
vbHidden 2 Specifies hidden files in addition to files with no attributes.
VbSystem 4 Specifies system files in addition to files with no attributes. Not available on the Macintosh.
vbVolume 8 Specifies volume label; if any other attributed is specified, vbVolume is ignored. Not available on the Macintosh.
vbDirectory 16 Specifies directories or folders in addition to files with no attributes.
vbAlias 64 Specified file name is an alias. Available only on the Macintosh.
From VBA Help, the attributes you can use for Dir$
Constant Value Description
vbNormal 0 (Default) Specifies files with no attributes.
vbReadOnly 1 Specifies read-only files in addition to files with no attributes.
vbHidden 2 Specifies hidden files in addition to files with no attributes.
VbSystem 4 Specifies system files in addition to files with no attributes. Not available on the Macintosh.
vbVolume 8 Specifies volume label; if any other attributed is specified, vbVolume is ignored. Not available on the Macintosh.
vbDirectory 16 Specifies directories or folders in addition to files with no attributes.
vbAlias 64 Specified file name is an alias. Available only on the Macintosh.
ASKER
:)