Save file as Read-Only

O

Otto Moehrbach

Excel XP & Win XP
I need to save a file in VBA and set the attribute to Read-Only. I know
how to save it but don't know how to set the attribute. What is the correct
code for that? Thanks for your time. Otto
 
G

Gary Keramidas

maybe something like this, just use your own variables:

Workbooks(wb).SaveAs Filename:=fPath & fName, ReadOnlyRecommended:=True
 
O

Otto Moehrbach

Gary
Thanks for your time. That didn't set the attribute such that when you
right-click on the file name - properties, you see the Read-Only box
checked. What it did create was a query when the file is opened asking if
you want to open it as Read-Only.
Do you know of a way to make the file Read-only such that when you open
it, it is Read-only, period?
 
J

Jim Cone

Otto,
The SetAttr statement only works on closed files...
Sub DoItToIt()
SetAttr "C:\My Documents\Word & Text Docs\MyFile.doc", vbReadOnly
End Sub
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware



"Otto Moehrbach" <[email protected]>
wrote in message
Excel XP & Win XP
I need to save a file in VBA and set the attribute to Read-Only. I know
how to save it but don't know how to set the attribute. What is the correct
code for that? Thanks for your time. Otto
 

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