Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default 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   Report Post  
Posted to microsoft.public.excel.programming
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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro to lock project from viewing CH Excel Programming 1 September 21st 07 04:49 PM
Unlock for Viewing Edmund Excel Worksheet Functions 0 May 2nd 06 05:08 AM
Unlock VBA Project zhj23 Excel Programming 1 October 8th 05 12:50 PM
Unlock VBA Project zhj23 Excel Discussion (Misc queries) 1 October 8th 05 12:14 PM
Unlock VBA project Gail Kling[_2_] Excel Programming 8 August 31st 04 06:25 PM


All times are GMT +1. The time now is 03:28 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"