Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi,
Is there a way to stop a macro from running if the worksbook has been opened as Read Only I have a file and all the worksheets are protected My macro unprotects and re-protects all the sheets. I have written the password in my macro and then protected my macro so no one can view. I dont want any body to know my password so that is why I have added to code. Only one other person other than me will be allowed to run the macro but I dot want that person to be able to unprotect any of the worksheets.So hence me writing the password in the code. However when I am read only the macro still runs Can you link a macro to a password on the workbook itself? or Tell the macro not to run if workbook has been opened as Read Only. Your advice appreciated as always. Thank you Winnie |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi,
You don't tell us how you call your code but you could do test for 'Read Only' in the workbook open event module Private Sub Workbook_Open() If ThisWorkbook.ReadOnly Then MsgBox "Read only" Else 'run my macro End If End Sub Mike "winnie123" wrote: Hi, Is there a way to stop a macro from running if the worksbook has been opened as Read Only I have a file and all the worksheets are protected My macro unprotects and re-protects all the sheets. I have written the password in my macro and then protected my macro so no one can view. I dont want any body to know my password so that is why I have added to code. Only one other person other than me will be allowed to run the macro but I dot want that person to be able to unprotect any of the worksheets.So hence me writing the password in the code. However when I am read only the macro still runs Can you link a macro to a password on the workbook itself? or Tell the macro not to run if workbook has been opened as Read Only. Your advice appreciated as always. Thank you Winnie |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Mike,
It didn't work it still allowed me to run the macro in read only. I get the message box read only but then I click on the macro and it still runs. Would it help if I posted my code ? "Mike H" wrote: Hi, You don't tell us how you call your code but you could do test for 'Read Only' in the workbook open event module Private Sub Workbook_Open() If ThisWorkbook.ReadOnly Then MsgBox "Read only" Else 'run my macro End If End Sub Mike "winnie123" wrote: Hi, Is there a way to stop a macro from running if the worksbook has been opened as Read Only I have a file and all the worksheets are protected My macro unprotects and re-protects all the sheets. I have written the password in my macro and then protected my macro so no one can view. I dont want any body to know my password so that is why I have added to code. Only one other person other than me will be allowed to run the macro but I dot want that person to be able to unprotect any of the worksheets.So hence me writing the password in the code. However when I am read only the macro still runs Can you link a macro to a password on the workbook itself? or Tell the macro not to run if workbook has been opened as Read Only. Your advice appreciated as always. Thank you Winnie |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi,
Would it help if I posted my code ? Probably yes but I still think this will work. If you run your macro by pressing a button or from tools macros then this should do it Sub MyMacro() If ThisWorkbook.ReadOnly Then Exit Sub 'Your code End Sub Mike "winnie123" wrote: Hi Mike, It didn't work it still allowed me to run the macro in read only. I get the message box read only but then I click on the macro and it still runs. Would it help if I posted my code ? "Mike H" wrote: Hi, You don't tell us how you call your code but you could do test for 'Read Only' in the workbook open event module Private Sub Workbook_Open() If ThisWorkbook.ReadOnly Then MsgBox "Read only" Else 'run my macro End If End Sub Mike "winnie123" wrote: Hi, Is there a way to stop a macro from running if the worksbook has been opened as Read Only I have a file and all the worksheets are protected My macro unprotects and re-protects all the sheets. I have written the password in my macro and then protected my macro so no one can view. I dont want any body to know my password so that is why I have added to code. Only one other person other than me will be allowed to run the macro but I dot want that person to be able to unprotect any of the worksheets.So hence me writing the password in the code. However when I am read only the macro still runs Can you link a macro to a password on the workbook itself? or Tell the macro not to run if workbook has been opened as Read Only. Your advice appreciated as always. Thank you Winnie |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Mike your a star
Thanks very much it has done the trick for me So very pleased I can rest in peace now :-) Winnie "Mike H" wrote: Hi, Would it help if I posted my code ? Probably yes but I still think this will work. If you run your macro by pressing a button or from tools macros then this should do it Sub MyMacro() If ThisWorkbook.ReadOnly Then Exit Sub 'Your code End Sub Mike "winnie123" wrote: Hi Mike, It didn't work it still allowed me to run the macro in read only. I get the message box read only but then I click on the macro and it still runs. Would it help if I posted my code ? "Mike H" wrote: Hi, You don't tell us how you call your code but you could do test for 'Read Only' in the workbook open event module Private Sub Workbook_Open() If ThisWorkbook.ReadOnly Then MsgBox "Read only" Else 'run my macro End If End Sub Mike "winnie123" wrote: Hi, Is there a way to stop a macro from running if the worksbook has been opened as Read Only I have a file and all the worksheets are protected My macro unprotects and re-protects all the sheets. I have written the password in my macro and then protected my macro so no one can view. I dont want any body to know my password so that is why I have added to code. Only one other person other than me will be allowed to run the macro but I dot want that person to be able to unprotect any of the worksheets.So hence me writing the password in the code. However when I am read only the macro still runs Can you link a macro to a password on the workbook itself? or Tell the macro not to run if workbook has been opened as Read Only. Your advice appreciated as always. Thank you Winnie |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Glad I could help
"winnie123" wrote: Mike your a star Thanks very much it has done the trick for me So very pleased I can rest in peace now :-) Winnie "Mike H" wrote: Hi, Would it help if I posted my code ? Probably yes but I still think this will work. If you run your macro by pressing a button or from tools macros then this should do it Sub MyMacro() If ThisWorkbook.ReadOnly Then Exit Sub 'Your code End Sub Mike "winnie123" wrote: Hi Mike, It didn't work it still allowed me to run the macro in read only. I get the message box read only but then I click on the macro and it still runs. Would it help if I posted my code ? "Mike H" wrote: Hi, You don't tell us how you call your code but you could do test for 'Read Only' in the workbook open event module Private Sub Workbook_Open() If ThisWorkbook.ReadOnly Then MsgBox "Read only" Else 'run my macro End If End Sub Mike "winnie123" wrote: Hi, Is there a way to stop a macro from running if the worksbook has been opened as Read Only I have a file and all the worksheets are protected My macro unprotects and re-protects all the sheets. I have written the password in my macro and then protected my macro so no one can view. I dont want any body to know my password so that is why I have added to code. Only one other person other than me will be allowed to run the macro but I dot want that person to be able to unprotect any of the worksheets.So hence me writing the password in the code. However when I am read only the macro still runs Can you link a macro to a password on the workbook itself? or Tell the macro not to run if workbook has been opened as Read Only. Your advice appreciated as always. Thank you Winnie |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Macro recorded... tabs & file names changed, macro hangs | Excel Worksheet Functions | |||
AutoRun Macro with a delay to give user the choice to cancel the macro | Excel Programming | |||
Macro Help Needed - Excel 2007 - Print Macro with Auto Sort | Excel Worksheet Functions | |||
Macro not showing in Tools/Macro/Macros yet show up when I goto VBA editor | Excel Programming | |||
Start Macro / Stop Macro / Restart Macro | Excel Programming |