Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Unlock project for viewing within a macro
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! |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Unlock project for viewing within a macro
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 |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Unlock project for viewing within a macro
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 "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! |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Macro to lock project from viewing | Excel Programming | |||
Unlock for Viewing | Excel Worksheet Functions | |||
Unlock VBA Project | Excel Programming | |||
Unlock VBA Project | Excel Discussion (Misc queries) | |||
Unlock VBA project | Excel Programming |