Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Read-Only Attribute???????

Status
Not open for further replies.

jennuhw

MIS
Apr 18, 2001
426
US
I have a script that opens another workbook. This workbook is read-only and password protected. Is there a way to disable this? Here is what I have tried in the script:
ChDir "\\esp1\company\customer service\sun hua test"
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFile(fs.GetFileName("sun hua master quote.xls"))
If f.Attributes = 33 Then
f.Attributes = 0
End If
Workbooks.Open Filename:=f
The if statement line, I have tried ReadOnly and 1 (that is what the VBA help lists as readonly.) I put 33 in there because that is what the watch said is the value. I am assuming that it is 33 because 1 is for readonly plus 32 for archive. Am I on the right track? Thanks!
 
Good deal! That worked. It is still asking me for the password to be able to edit the worksheet. Is there a way around this?
 
Oops. I have tried it again, and it doesn't work. I think it is because I have it checked in the options of the particular spreadsheet. I am thinking that the attributes command is at the file level, correct?
 
I have figured it out! I ended up getting rid of all of the code above and just doing:
Workbooks.Open Filename:="filename", WriteResPassword:="password"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top