Setting a File Attribute to Hidden

M

Mota

Hello;
I want to change attribute of a table-based text file saved outside my
program (to prevent it from accidental handling by the user) and set it to
hidden through code.How to do it?
Thank you so much in advance.
 
N

Nikos Yannacopoulos

Try this:

Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFile("c:\MyFile.txt")
f.Attributes = 2

(modify path and file name accordingly).

Nikos
 
D

Dirk Goldgar

Nikos Yannacopoulos said:
Try this:

Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFile("c:\MyFile.txt")
f.Attributes = 2

(modify path and file name accordingly).

Nikos

Don't you think that's overkill, for a function that is built right into
VBA? Why not just

SetAttr "c:\MyFile.txt", vbHidden

?
 
N

Nikos Yannacopoulos

Dirk,

Thanks for the tip!

Nikos
-----Original Message-----


Don't you think that's overkill, for a function that is built right into
VBA? Why not just

SetAttr "c:\MyFile.txt", vbHidden

?
--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)


.
 

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