Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 24
Default My Macros will not work after I protect my document.

Is there any way to make macros work once my document is protected? If so how?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 586
Default My Macros will not work after I protect my document.

If you are changing anything on the worksheet and the worksheet is protected
then you will get an error. You need to Unprotect the worksheet, run your
code, then Protect it again.

Sub Protect90()

Sheets("Sheet1").Unprotect "password"

'your code here

Sheets("Sheet1").Protect "password"

End Sub

Ryan

"Samantha" wrote:

Is there any way to make macros work once my document is protected? If so how?

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 24
Default My Macros will not work after I protect my document.

What?
Where would I put that? I have multiple macros on each sheet of my
workbook...am i supposed to put this in each of my macros? what will this
macro do?

"RyanH" wrote:

If you are changing anything on the worksheet and the worksheet is protected
then you will get an error. You need to Unprotect the worksheet, run your
code, then Protect it again.

Sub Protect90()

Sheets("Sheet1").Unprotect "password"

'your code here

Sheets("Sheet1").Protect "password"

End Sub

Ryan

"Samantha" wrote:

Is there any way to make macros work once my document is protected? If so how?

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,101
Default My Macros will not work after I protect my document.

In my experience, if you protect the workBOOK, macros will not run. They
should still run with a protected worksheet though.

"Samantha" wrote:

Is there any way to make macros work once my document is protected? If so how?

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 24
Default My Macros will not work after I protect my document.

No im protecting the workSHEET

"mike" wrote:

In my experience, if you protect the workBOOK, macros will not run. They
should still run with a protected worksheet though.

"Samantha" wrote:

Is there any way to make macros work once my document is protected? If so how?



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,101
Default My Macros will not work after I protect my document.

Try saving as file type 'macro enabled workbook' in the save as filetype
dropdown. That worked for me with a protected sheet with macros.

"Samantha" wrote:

No im protecting the workSHEET

"mike" wrote:

In my experience, if you protect the workBOOK, macros will not run. They
should still run with a protected worksheet though.

"Samantha" wrote:

Is there any way to make macros work once my document is protected? If so how?

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default My Macros will not work after I protect my document.

Anything you can not do manually on a protected spreadsheet will also not
work in a macro... The only exclusion to that rule is if you protected the
sheet in code and added the parameter UserInterfaceOnly:=True. At that point
macros will have some abilities that can not be done manually. That being
said UserInterfaceOnly is a bit hit and miss so it may not be worth doing.
--
HTH...

Jim Thomlinson


"mike" wrote:

Try saving as file type 'macro enabled workbook' in the save as filetype
dropdown. That worked for me with a protected sheet with macros.

"Samantha" wrote:

No im protecting the workSHEET

"mike" wrote:

In my experience, if you protect the workBOOK, macros will not run. They
should still run with a protected worksheet though.

"Samantha" wrote:

Is there any way to make macros work once my document is protected? If so how?

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default My Macros will not work after I protect my document.

Add that code at the beginning and the end of each macro. You need to do it
for each sheet you intend to modify. If you want to post one of your macros,
we can add the necessary code to show you what we mean...
--
HTH...

Jim Thomlinson


"Samantha" wrote:

What?
Where would I put that? I have multiple macros on each sheet of my
workbook...am i supposed to put this in each of my macros? what will this
macro do?

"RyanH" wrote:

If you are changing anything on the worksheet and the worksheet is protected
then you will get an error. You need to Unprotect the worksheet, run your
code, then Protect it again.

Sub Protect90()

Sheets("Sheet1").Unprotect "password"

'your code here

Sheets("Sheet1").Protect "password"

End Sub

Ryan

"Samantha" wrote:

Is there any way to make macros work once my document is protected? If so how?

  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 586
Default My Macros will not work after I protect my document.

Does an error pop up? If so, click "Debug". Then you will see a line at the
top of the procedure that looks something like "Sub Macro1()". Under that
line put this code:

Dim sh As Worksheet

For Each sh In Worksheets
sh.Unprotect
Next sh

'your macro syntax here

then, at the end of the procedure you need to put this:

For Each sh In Worksheets
sh.Protect
Next sh

End Sub

NOTE: If you entered a password when you protected the worksheet add "
Password:= "Your Password Here" directly next to sh.Unprotect and sh.Protect

Hope this helps!

--
Cheers,
Ryan


"Samantha" wrote:

What?
Where would I put that? I have multiple macros on each sheet of my
workbook...am i supposed to put this in each of my macros? what will this
macro do?

"RyanH" wrote:

If you are changing anything on the worksheet and the worksheet is protected
then you will get an error. You need to Unprotect the worksheet, run your
code, then Protect it again.

Sub Protect90()

Sheets("Sheet1").Unprotect "password"

'your code here

Sheets("Sheet1").Protect "password"

End Sub

Ryan

"Samantha" wrote:

Is there any way to make macros work once my document is protected? If so how?

  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 24
Default My Macros will not work after I protect my document.

Sub Create_New_Entry()

Rows("24:24").Select
Selection.Insert Shift:=xlDown
Range("E23:R23").Select
Selection.AutoFill Destination:=Range("E23:R24"), Type:=xlFillDefault
Range("B24").Select
End Sub



  #11   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 24
Default My Macros will not work after I protect my document.

Sub Create_New_Entry()

Rows("24:24").Select
Selection.Insert Shift:=xlDown
Range("E23:R23").Select
Selection.AutoFill Destination:=Range("E23:R24"), Type:=xlFillDefault
Range("B24").Select
End Sub

  #12   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 586
Default My Macros will not work after I protect my document.

Sub Create_New_Entry()

Activesheet.Unprotect

Rows("24:24").Select
Selection.Insert Shift:=xlDown
Range("E23:R23").Select
Selection.AutoFill Destination:=Range("E23:R24"), Type:=xlFillDefault
Range("B24").Select

Activesheet.Protect

End Sub
--
Cheers,
Ryan


"Samantha" wrote:

Sub Create_New_Entry()

Rows("24:24").Select
Selection.Insert Shift:=xlDown
Range("E23:R23").Select
Selection.AutoFill Destination:=Range("E23:R24"), Type:=xlFillDefault
Range("B24").Select
End Sub

  #13   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22,906
Default My Macros will not work after I protect my document.

Mike

Is this a feature of Excel 2007?

In earlier version. macros will run on protected workBOOKS


Gord Dibben MS Excel MVP


On Tue, 24 Jun 2008 13:41:01 -0700, mike wrote:

In my experience, if you protect the workBOOK, macros will not run. They
should still run with a protected worksheet though.

"Samantha" wrote:

Is there any way to make macros work once my document is protected? If so how?


  #14   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,101
Default My Macros will not work after I protect my document.

sry for the off topic Samantha . . .

I was using 2007 when I found that my macro wouldn't run on a protected
workbook. It took me days to figure out what was goin wrong and several hours
in this forum - No one was able to help me.

"Gord Dibben" wrote:

Mike

Is this a feature of Excel 2007?

In earlier version. macros will run on protected workBOOKS


Gord Dibben MS Excel MVP


On Tue, 24 Jun 2008 13:41:01 -0700, mike wrote:

In my experience, if you protect the workBOOK, macros will not run. They
should still run with a protected worksheet though.

"Samantha" wrote:

Is there any way to make macros work once my document is protected? If so how?



  #15   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default My Macros will not work after I protect my document.

Mike... did you ever find out what to do to be able to run macros on a
password protected workbook? Would appreciate your help before I go crazy!

Roger.


"mike" wrote:

sry for the off topic Samantha . . .

I was using 2007 when I found that my macro wouldn't run on a protected
workbook. It took me days to figure out what was goin wrong and several hours
in this forum - No one was able to help me.

"Gord Dibben" wrote:

Mike

Is this a feature of Excel 2007?

In earlier version. macros will run on protected workBOOKS


Gord Dibben MS Excel MVP


On Tue, 24 Jun 2008 13:41:01 -0700, mike wrote:

In my experience, if you protect the workBOOK, macros will not run. They
should still run with a protected worksheet though.

"Samantha" wrote:

Is there any way to make macros work once my document is protected? If so how?



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
how can i protect a document so nobody can delete it jenniss Excel Discussion (Misc queries) 1 January 14th 05 11:53 PM
how can i protect a document so nobody can delete it jenniss Excel Discussion (Misc queries) 1 January 14th 05 12:30 PM
weird saving of a document with macros resulting with macros being transfered to the copy alfonso gonzales Excel Programming 0 December 12th 04 09:19 PM
Best way to protect sheets and document. Luong[_2_] Excel Programming 1 June 29th 04 02:18 PM
Password protect an Excel document Paul B[_7_] Excel Programming 1 September 17th 03 06:47 PM


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

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

About Us

"It's about Microsoft Excel"