Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() I'm trying to create a macro that will protect and unprotect 10 sheets in a workbook. i have the code to protect etc. i'm having a problem he i created a form named frmPassword where i have a text field called My_Password. what code would i use to open up that form and enter in a password, then when i click ok to assign whatever was in My_Password to a variable called My_Pass. I tried My_Pass=frmPassword.My_Password but that doesnt work, probably because i never opened the form. any help? -- tkaplan ------------------------------------------------------------------------ tkaplan's Profile: http://www.excelforum.com/member.php...o&userid=22987 View this thread: http://www.excelforum.com/showthread...hreadid=376377 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
1) Wherever you want to open the form from:
Load frmPassword frmPassword.Show Unload frmPassword 2) In the VB editor, Insert a Module (InsertModule), if you don't already have one. This needs to be in a General Module NOT a Form, Workbook, Worksheet, Class or other Object module. Place the following at the top (right below any Option Explicit statement and before any subs or functions): Public My_Pass as String Give the module a name and save it: 3) In the Click event of your "OK" button on frmPassword: My_Pass=Me.My_Password frmPassword.Hide (where My_Password is the name of the textbox on frmPassword) The value entered on frmPassword should now be available to you throughout the project in any VBA code as My_Pass. HTH, -- George Nicholson Remove 'Junk' from return address. "tkaplan" wrote in message ... I'm trying to create a macro that will protect and unprotect 10 sheets in a workbook. i have the code to protect etc. i'm having a problem he i created a form named frmPassword where i have a text field called My_Password. what code would i use to open up that form and enter in a password, then when i click ok to assign whatever was in My_Password to a variable called My_Pass. I tried My_Pass=frmPassword.My_Password but that doesnt work, probably because i never opened the form. any help? -- tkaplan ------------------------------------------------------------------------ tkaplan's Profile: http://www.excelforum.com/member.php...o&userid=22987 View this thread: http://www.excelforum.com/showthread...hreadid=376377 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Formula (off form) that completes form data based on a result | Excel Worksheet Functions | |||
Using a template form, advance a form number everytime you open | Excel Discussion (Misc queries) | |||
Can a form made in Excel 2002 be converted into a fillable form? | Excel Discussion (Misc queries) | |||
how can I make a form number change everytime the form is opened | Excel Worksheet Functions | |||
Is it possible to open the VBA form with a link in a sheet and to pass variable from a cell to the VBA form? | Excel Programming |