savecopyas read only

A

Anders

Hi - xl 03, rdb 6 (modified to save entire workbook)

I use the code below to save the entire workbook modified from rdb 6 copy
code. I've inserted the following savecopyas to accopmlish, but would like
it to be read only and can't figure out throug the help to do this.

TIA,
Anders

Sourcewb.SaveCopyAs (FolderName _
& "\" & "Archived Copy" & " " & "as of" & " " &
DateString & ".xls")
 
J

Jacob Skaria

strFile = "Archived Copy" & " " & "as of" & " " & _
DateString & ".xls"

Sourcewb.SaveAs Filename:=FolderName & "\" & strFile, _
FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=True

'Set password if you need.

If this post helps click Yes
 
D

Dave Peterson

Do your .SaveCopyAs, then open that workbook and save it the way you want, then
close that workbook.

Dim myName as string
dim TempWkbk as workbook

myname = FolderName & "\" & "Archived Copy" & " " & "as of" _
& " " & DateString & ".xls")

sourcewb.savecopyas filename:=myName

set tempwkbk = workbooks.open(filename:=myname)
with tempwkbk
application.displayalerts = false 'hide that "overwrite prompt"
.saveas filename:=myname, WriteResPassword:="yourpassword"
application.displayalerts = true
.close savechanges:=false
end with

(Untested, uncompiled. Watch for typos.)

====
With Screenupdating set to false, you won't know that it was opened, saved, and
closed.
 
A

Anders

Jacob - works great thanks!

Dave - Same! The only typo is the ( is missing in = FolderName

Really -- thank you both for the quick responses!

Best,
Anders
 
D

Dave Peterson

Actually, the
myname = foldername & ... & ".xls")
had an EXTRA ) at the end. It isn't necessary.

And be aware that there is a difference in Jacob's suggestion and mine.

Jacob's code will have the new file (.saveas) as the activeworkbook.

My code won't touch the current workbook (since it uses .savecopyas).
 

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