Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5
Default pass variable from one workbook to another

I have some workbooks that upon opening ask for a password. If the password
is incorrect or not supplied then it opens in a read only format. I have a
form that gets a username and password and if it is a certain password it
opens all the excel files in a folder. If this is the case I don't want each
file to open with the input box asking for the password. I want them all to
open in editable format. Can I pass the input box password and eliminate the
box all together. Here is the code for the workbook open which is on all the
excel workbooks that will be opening.

Private Sub Workbook_Open()
Dim psswd As Variant

psswd = InputBox("Please Click Enter", "Password", "Read Only")

If psswd = "j5rt342" Then

Else
'ThisWorkbook.ChangeFileAccess xlReadOnly
Application.Run "'master.xls'!selectingallworksheets"
Application.Run "'master.xls'!unprotecting"
Application.Run "'master.xls'!selectingallworksheets"
Range("A13:M21").Select
Range("A14").Activate
Selection.Locked = True
Selection.FormulaHidden = False
Application.Run "'master.xls'!protecting"
MsgBox ("The document is open in Read Only status, if you notice anything
wrong, please contact your administrator")
End If

End Sub
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5,441
Default pass variable from one workbook to another

I would use an add-in file that has a place to store the password temporarily, and access it with
this, at the top of each workbook open event:

If Workbooks("Add in name.xla").Worksheets("Sheet name").Range("A1").Value = "" Then
psswd = InputBox("Please Click Enter", "Password", "Read Only")
Workbooks("Add in name.xla").Worksheets("Sheet name").Range("A1").Value = psswd
'prevent the user from being asked to overwrite the add-in because of the change
Workbooks("Add in name.xla").Saved = True
Else
psswd = Workbooks("Add in name.xla").Worksheets("Sheet name").Range("A1").Value
End If

If psswd = "j5rt342" Then
'Other Code


When you create the add-in just make sure that the storage cell is blank prior to saving.

HTH,
Bernie
MS Excel MVP


"calebjill" wrote in message
...
I have some workbooks that upon opening ask for a password. If the password
is incorrect or not supplied then it opens in a read only format. I have a
form that gets a username and password and if it is a certain password it
opens all the excel files in a folder. If this is the case I don't want each
file to open with the input box asking for the password. I want them all to
open in editable format. Can I pass the input box password and eliminate the
box all together. Here is the code for the workbook open which is on all the
excel workbooks that will be opening.

Private Sub Workbook_Open()
Dim psswd As Variant

psswd = InputBox("Please Click Enter", "Password", "Read Only")

If psswd = "j5rt342" Then

Else
'ThisWorkbook.ChangeFileAccess xlReadOnly
Application.Run "'master.xls'!selectingallworksheets"
Application.Run "'master.xls'!unprotecting"
Application.Run "'master.xls'!selectingallworksheets"
Range("A13:M21").Select
Range("A14").Activate
Selection.Locked = True
Selection.FormulaHidden = False
Application.Run "'master.xls'!protecting"
MsgBox ("The document is open in Read Only status, if you notice anything
wrong, please contact your administrator")
End If

End Sub



  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5
Default pass variable from one workbook to another

Worked great. Thanks

"Bernie Deitrick" wrote:

I would use an add-in file that has a place to store the password temporarily, and access it with
this, at the top of each workbook open event:

If Workbooks("Add in name.xla").Worksheets("Sheet name").Range("A1").Value = "" Then
psswd = InputBox("Please Click Enter", "Password", "Read Only")
Workbooks("Add in name.xla").Worksheets("Sheet name").Range("A1").Value = psswd
'prevent the user from being asked to overwrite the add-in because of the change
Workbooks("Add in name.xla").Saved = True
Else
psswd = Workbooks("Add in name.xla").Worksheets("Sheet name").Range("A1").Value
End If

If psswd = "j5rt342" Then
'Other Code


When you create the add-in just make sure that the storage cell is blank prior to saving.

HTH,
Bernie
MS Excel MVP


"calebjill" wrote in message
...
I have some workbooks that upon opening ask for a password. If the password
is incorrect or not supplied then it opens in a read only format. I have a
form that gets a username and password and if it is a certain password it
opens all the excel files in a folder. If this is the case I don't want each
file to open with the input box asking for the password. I want them all to
open in editable format. Can I pass the input box password and eliminate the
box all together. Here is the code for the workbook open which is on all the
excel workbooks that will be opening.

Private Sub Workbook_Open()
Dim psswd As Variant

psswd = InputBox("Please Click Enter", "Password", "Read Only")

If psswd = "j5rt342" Then

Else
'ThisWorkbook.ChangeFileAccess xlReadOnly
Application.Run "'master.xls'!selectingallworksheets"
Application.Run "'master.xls'!unprotecting"
Application.Run "'master.xls'!selectingallworksheets"
Range("A13:M21").Select
Range("A14").Activate
Selection.Locked = True
Selection.FormulaHidden = False
Application.Run "'master.xls'!protecting"
MsgBox ("The document is open in Read Only status, if you notice anything
wrong, please contact your administrator")
End If

End Sub




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
Pass workbook name to ActiveX DLL (VB6) meldrum_scotland Excel Discussion (Misc queries) 0 August 8th 08 06:07 PM
Cells.Find: Why can't I pass a variable? Rick S. Excel Discussion (Misc queries) 10 October 4th 07 07:50 PM
Pass variable to NORMINSV function to get only mean value ExcelMonkey Excel Worksheet Functions 3 June 19th 06 06:01 PM
How to pass a variable into an SQL statement CLamar Excel Discussion (Misc queries) 0 June 5th 06 02:17 PM
How to (re)set a range.value to pass -0- to a "double" variable Dennis Excel Discussion (Misc queries) 2 April 15th 05 11:13 AM


All times are GMT +1. The time now is 02:34 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"