Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 109
Default open w/book with password

The following userform code asking for a password to open another w/book..
at which line I should insert code,(what code) to open another w/book called
"sales"
Private Sub cmdLogin_Click()
With Me.TextBox1
If .Text < ThisWorkbook.Worksheets("Sheet1") _
Range("R1").Value Then 'sheet1cell"R1" contains password
MsgBox "Invalid Password !", vbCritical
SelStart = 0
SelLength = Len(.Text)
SetFocus
Else: Unload Me
End If
End With
End Sub

--
Message posted via http://www.officekb.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,565
Default open w/book with password

The following userform code asking for a password to open another w/book..
at which line I should insert code,(what code) to open another w/book called
"sales"
Private Sub cmdLogin_Click()
With Me.TextBox1
If .Text < ThisWorkbook.Worksheets("Sheet1") _
Range("R1").Value Then 'sheet1cell"R1" contains password
MsgBox "Invalid Password !", vbCritical
'assumes current path and xl2003 or earlier, if xl2007, need file ext.
mod.
Workbooks.Open (ThisWorkbook.Path & "\sales.xls", Password:="<password"
SelStart = 0
SelLength = Len(.Text)
SetFocus
Else: Unload Me
End If
End With
End Sub




"tkraju via OfficeKB.com" <u16627@uwe wrote in message
news:94cd3cd633d9e@uwe...
The following userform code asking for a password to open another
w/book..
at which line I should insert code,(what code) to open another w/book
called
"sales"
Private Sub cmdLogin_Click()
With Me.TextBox1
If .Text < ThisWorkbook.Worksheets("Sheet1") _
Range("R1").Value Then 'sheet1cell"R1" contains password
MsgBox "Invalid Password !", vbCritical
SelStart = 0
SelLength = Len(.Text)
SetFocus
Else: Unload Me
End If
End With
End Sub

--
Message posted via http://www.officekb.com



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 109
Default open w/book with password

Am I to Write workbook path under brackets ?

JLGWhiz wrote:
The following userform code asking for a password to open another w/book..
at which line I should insert code,(what code) to open another w/book called
"sales"
Private Sub cmdLogin_Click()
With Me.TextBox1
If .Text < ThisWorkbook.Worksheets("Sheet1") _
Range("R1").Value Then 'sheet1cell"R1" contains password
MsgBox "Invalid Password !", vbCritical
'assumes current path and xl2003 or earlier, if xl2007, need file ext.
mod.
Workbooks.Open (ThisWorkbook.Path & "\sales.xls", Password:="<password"
SelStart = 0
SelLength = Len(.Text)
SetFocus
Else: Unload Me
End If
End With
End Sub

The following userform code asking for a password to open another
w/book..

[quoted text clipped - 13 lines]
End With
End Sub


--
Message posted via http://www.officekb.com

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default open w/book with password

Where you see <password, means you provide that string, without the
brackets. Everything else is as written. This corrects a typo in my
original posting.

Workbooks.Open (ThisWorkbook.Path & "\sales.xls", Password:="<password")

If you are using xl2007, the .xls file extension will need to be changed to
a four digit string, probably .xlsm

"tkraju via OfficeKB.com" wrote:

Am I to Write workbook path under brackets ?

JLGWhiz wrote:
The following userform code asking for a password to open another w/book..
at which line I should insert code,(what code) to open another w/book called
"sales"
Private Sub cmdLogin_Click()
With Me.TextBox1
If .Text < ThisWorkbook.Worksheets("Sheet1") _
Range("R1").Value Then 'sheet1cell"R1" contains password
MsgBox "Invalid Password !", vbCritical
'assumes current path and xl2003 or earlier, if xl2007, need file ext.
mod.
Workbooks.Open (ThisWorkbook.Path & "\sales.xls", Password:="<password"
SelStart = 0
SelLength = Len(.Text)
SetFocus
Else: Unload Me
End If
End With
End Sub

The following userform code asking for a password to open another
w/book..

[quoted text clipped - 13 lines]
End With
End Sub


--
Message posted via http://www.officekb.com


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default open w/book with password

I also overlooked that you have your password in cell R1 of Sheet 1 of the
workbook which is running the code. So here is a modified version that
should work. Also, on the Workbooks.Open line, if the "sales" wb is not in
the same folder as the ThisWorkbook, you will need to modify the path to
include the correct folder.

Private Sub cmdLogin_Click()
With Me.TextBox1
If .Text < ThisWorkbook.Worksheets("Sheet1") _
Range("R1").Value Then 'sheet1cell"R1" contains password
MsgBox "Invalid Password !", vbCritical
Else
pw = ThisWorkbook.Worksheets("Sheet1").Range("R1").Valu e
'assumes current path and xl2003 or earlier, if xl2007, need file ext.
mod.
Workbooks.Open (ThisWorkbook.Path & "\sales.xls", Password:=pw)
SelStart = 0
SelLength = Len(.Text)
SetFocus
Else: Unload Me
End If
End With
End Sub



"JLGWhiz" wrote:

Where you see <password, means you provide that string, without the
brackets. Everything else is as written. This corrects a typo in my
original posting.

Workbooks.Open (ThisWorkbook.Path & "\sales.xls", Password:="<password")

If you are using xl2007, the .xls file extension will need to be changed to
a four digit string, probably .xlsm

"tkraju via OfficeKB.com" wrote:

Am I to Write workbook path under brackets ?

JLGWhiz wrote:
The following userform code asking for a password to open another w/book..
at which line I should insert code,(what code) to open another w/book called
"sales"
Private Sub cmdLogin_Click()
With Me.TextBox1
If .Text < ThisWorkbook.Worksheets("Sheet1") _
Range("R1").Value Then 'sheet1cell"R1" contains password
MsgBox "Invalid Password !", vbCritical
'assumes current path and xl2003 or earlier, if xl2007, need file ext.
mod.
Workbooks.Open (ThisWorkbook.Path & "\sales.xls", Password:="<password"
SelStart = 0
SelLength = Len(.Text)
SetFocus
Else: Unload Me
End If
End With
End Sub

The following userform code asking for a password to open another
w/book..
[quoted text clipped - 13 lines]
End With
End Sub


--
Message posted via http://www.officekb.com




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 109
Default open w/book with password

Thank you so much.

JLGWhiz wrote:
Where you see <password, means you provide that string, without the
brackets. Everything else is as written. This corrects a typo in my
original posting.

Workbooks.Open (ThisWorkbook.Path & "\sales.xls", Password:="<password")

If you are using xl2007, the .xls file extension will need to be changed to
a four digit string, probably .xlsm

Am I to Write workbook path under brackets ?

[quoted text clipped - 22 lines]
End With
End Sub


--
Message posted via http://www.officekb.com

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
linking to a password protected book Ryancompplan Excel Discussion (Misc queries) 0 February 3rd 09 10:18 PM
'BeforeClose' code problems:book won't close if more than one book is open Ed from AZ Excel Programming 0 September 18th 07 03:59 PM
PASSWORD REMOVAL I have the password to open the file and the password to modify the file now how to remove them LJ[_4_] Excel Programming 0 April 27th 06 03:18 AM
Open book, check for macros, close book Robin Hammond[_2_] Excel Programming 5 March 31st 05 06:09 PM


All times are GMT +1. The time now is 05:21 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"