ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Macros in Template (https://www.excelbanter.com/excel-programming/285992-macros-template.html)

Dick Johnson

Macros in Template
 
Hi all,

I have developed a template form to collect data. The data
after being entered on the form it is stored on additional
sheets within the workbook for collect later.

I have written & stored 2 marcos within the workbook. One
protects the sheet from users selecting locked cells &
hides the additional sheets in the workbook. The other
unprotects the sheet & unhides the additional sheets.

I have saved the template after using the 'Protect' marco.

My problem is this:

When the template is opened as a new workbook the locked
cells are available to the user. I can still manually
activate the 'Protect' macro to block access to the locked
cells.

Is there something Im doing wrong in the 'set-up'
or 'programing'? or
Can a macro be set to activate when a new workbook is
opened?

Thanks for any assitance on this matter.

Dick Johnson

Amit Shanker

Macros in Template
 
Private Sub Workbook_Open
'Your code goes here
'
'
End Sub

This will fire the macro as soon as you open the workbook.

Amit


"Dick Johnson" wrote in message
...
Hi all,

I have developed a template form to collect data. The data
after being entered on the form it is stored on additional
sheets within the workbook for collect later.

I have written & stored 2 marcos within the workbook. One
protects the sheet from users selecting locked cells &
hides the additional sheets in the workbook. The other
unprotects the sheet & unhides the additional sheets.

I have saved the template after using the 'Protect' marco.

My problem is this:

When the template is opened as a new workbook the locked
cells are available to the user. I can still manually
activate the 'Protect' macro to block access to the locked
cells.

Is there something Im doing wrong in the 'set-up'
or 'programing'? or
Can a macro be set to activate when a new workbook is
opened?

Thanks for any assitance on this matter.

Dick Johnson




Dick Johnson

Macros in Template
 
Thanks Amit, problem solved

-----Original Message-----
Private Sub Workbook_Open
'Your code goes here
'
'
End Sub

This will fire the macro as soon as you open the workbook.

Amit


"Dick Johnson" wrote in message
...
Hi all,

I have developed a template form to collect data. The

data
after being entered on the form it is stored on

additional
sheets within the workbook for collect later.

I have written & stored 2 marcos within the workbook.

One
protects the sheet from users selecting locked cells &
hides the additional sheets in the workbook. The other
unprotects the sheet & unhides the additional sheets.

I have saved the template after using the 'Protect'

marco.

My problem is this:

When the template is opened as a new workbook the locked
cells are available to the user. I can still manually
activate the 'Protect' macro to block access to the

locked
cells.

Is there something Im doing wrong in the 'set-up'
or 'programing'? or
Can a macro be set to activate when a new workbook is
opened?

Thanks for any assitance on this matter.

Dick Johnson



.



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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com