Saving a File as read only with no prompts to save

D

DoctorV

I have some macros I run off of a button that removes all VBA Code fro
an Excel workbook and then saves the file to a new name. The problem
am having is that I want to save it to a new name as ReadOnly and no
be prompted to save it. Here was the code I was attempting to use, bu
this only allows ReadOnlyrecommended. How can I get this to Save th
file to this name, As readOnly and then close and not prompt for
save? Here is my current code. Thanks

I absolutely must have this saved as a Read Only no
ReadOnlyRecommended

Sub SaveName()

ActiveWorkbook.SaveAs Filename:="C:\MyFile.xls"
ReadOnlyRecommended:=True
ActiveWorkbook.Close SaveChanges:=True
End Su
 
T

Tom Ogilvy

Sub SaveName()
Dim sName as String
ActiveWorkbook.SaveAs Filename:="C:\MyFile.xls", _
ReadOnlyRecommended:=True
sName = Activeworkbook.FullName
ActiveWorkbook.Close SaveChanges:=False ' you just saved it
setattr sName, 1
End Sub
 
D

DoctorV

I wanted to make sure and save it as ReaOnly not ReadOnly Recommende
because then the user could open the file with full privileges
 
T

Tom Ogilvy

And I showed you how to make it readonly with setattr

There isn't an option in SaveAs to mark it as readonly.
 

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