turning Read Only files into Read/Write with

P

Paul

I'm using the following code to make copies of files on a network drive:

Dim fso As Object
Set fso = CreateObject("Scripting.FileSystemObject")
fso.CopyFile strTemplateFile, strProjectFile

When the procedure runs, some of the source files are Read Only, and I'd
like to remove that Read Only attribute at the time I make the copy - so the
copied file doesn't retain the Read-Only attribute.

Is there a parameter I can add to the CopyFile line above, to remove the
Read Only attribute - or is there is also another way to accomplish this?

Thanks in advance,

Paul
 
K

Klatuu

I would not use the fso. Here is how I would do it:

FileCopy strTemplateFile, strProjectFile
SetAttr strProjectFile, vbNormal
 
P

Paul

Ah - that's what I was looking for.

Before posting my question in the newsgroup here, I did a Web search and
came across some suggestions about first testing to see if it was Read Only,
and then using XOR as a toggle switch, but it seemed that was going through
more steps than a simple, unconditional command to disable Read Only if it
had been turned on.

I was using FileCopy for a while, but we ran into some problems in that some
of our users were getting messages saying the copy wasn't successful -
having something to do with permissions. Even though, as best I could tell,
they really did have permissions into the target folder. But I have found
that the same users, copying files into those same folders, don't run into
that problem if I use the File System Object.

In any event, thanks for showing me how to turn off the Read Only attribute,
Dave.

Paul
 

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