#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Form VBA


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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 170
Default Form VBA

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
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
Formula (off form) that completes form data based on a result lldiel Excel Worksheet Functions 2 November 24th 09 11:09 PM
Using a template form, advance a form number everytime you open ShoDan Excel Discussion (Misc queries) 1 January 31st 08 01:34 PM
Can a form made in Excel 2002 be converted into a fillable form? Paraclete Excel Discussion (Misc queries) 1 February 20th 07 09:20 PM
how can I make a form number change everytime the form is opened babydumplingspita Excel Worksheet Functions 1 October 10th 05 07:58 PM
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? Daniel[_14_] Excel Programming 1 August 29th 04 01:20 PM


All times are GMT +1. The time now is 09:52 AM.

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"