|
-
Mar 1st, 2004, 11:18 AM
#1
Thread Starter
New Member
Problem with Excel add-in
Hi.
I create a little add-in to save Excel files with a password protection. With this add-in you save your files with read/open password (it save the passwords in a txt file). When you open the file with double click the add-in should open the file automatically (the add-in compare the passwords in the txt file and if the password is the same it open the file automatically). I use the AutoOpen event to make this action.
But I have a problem. When I make double click in the protected file the Excel open the file and immediately close it and the Excel request me the password again.
Does anybody know how could I fix it?
-
Mar 2nd, 2004, 06:44 AM
#2
Addicted Member
I think we will need to see your code.
Regards
BrianB
-------------------------------
-
Mar 2nd, 2004, 09:55 AM
#3
Thread Starter
New Member
Originally posted by BrianB
I think we will need to see your code.
Sure BrianB, this is the code
--------------------------------------------------------------------------------
Sub Auto_Open
Call TryPwrd
End Sub
Sub TryPwrd()
Dim path As String
Dim Lines As String
Dim FileList As Collection
Dim i As Integer
Dim arr() As String
path = ShowFileOpenDialog(FileList)
If path <> "" Then
If OpenNoPwrd(path) Then Exit Sub
Application.DisplayAlerts = False
Open RUTA For Input As #1 'RUTA= c:\PWRDS.txt
i = 1
Do Until EOF(1)
Line Input #1, Lines
arr() = Split(Expression:=Lines, Delimiter:="|")
If OpenPwrd(path, arr(2)) Then
Exit Sub
End If
i = i + 1
Loop
Close #1
MsgBox "La clave no existe dentro de la lista"
End If
Application.DisplayAlerts = True
End Sub
Function OpenNoPwrd(path As String) As Boolean
On Error Resume Next
Workbooks.Open path, , , , ""
If Err.Number = 0 Then
OpenNoPwrd = True
tcurrentPassword.PwrdOpen = ""
End If
End Function
Function OpenPwrd(path As String, Pwrd As String) As Boolean
On Error Resume Next
Workbooks.Open path, , True, , Pwrd, , True, , , , False
If Err.Number = 0 Then
tcurrentPassword.PwrdOpen = Pwrd
OpenPwrd = True
End If
End Function
--------------------------------------------------------------------------------
The form save the passwords in the txt is this manner:
Application|Titulo|Password|Memo (separated with horizontal bars)
Regards.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|