View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
P McConnell[_2_] P McConnell[_2_] is offline
external usenet poster
 
Posts: 2
Default Unlock project for viewing within a macro

It appears that my reply was not added to the thread. This is my first
attempt at using the discussion group, please forgive the duplication.

....When protected and trying to rename, from FileSave As I get two messages.
"You cannot save to this file format when the VBA project is protected."
followed by "Document not saved". From the button on the userform where the
code is I get a 1004 with "You cannot save to this file format when the VBA
project is protected." I tried including the file format in the code (below)
and got the same results. BTW I'm in Excel 2003.

ActiveWorkbook.SaveAs Filename:="C:\Orders\" & ConNum & ".xls", FileFormat:=
xlNormal, AddToMru:=True

Thanks Again

"Dave Peterson" wrote:

You should be able to save the workbook with the project locked or unlocked.

What happened when you tried it?

P McConnell wrote:

I'd like to protect the macros in a workbook but allow the user to save it as
a different filename. Once I lock the VBAProject I can't save as another
name. I'm thinking a solution would be to wrap unprotect and re-protect
around the save (if that's possible), but I'm stumped on the code. Please
see below...

'I need code to unprotect project here
ConNum = TextBox1.Value
ActiveWorkbook.SaveAs Filename:="C:\Orders\" & ConNum & ".xls"
Application.RecentFiles.Add Name:=ThisWorkbook.FullName
'Also code to protect project here

Thanks!


--

Dave Peterson