Global Const for password

E

eggpap

Hello,

I have a Global Const PWORD = "pwrd" declared in a wb module of Excel.
Then I have written a macro to Unprotect and another to re-Protect al
the wb sheets. Now I'ld like to create a macro to change the passwor
periodically. My question is: is it possible to re-declare PWOR
programmatically without using a file to store its value? Or, in othe
words, how you'ld do?

Emilian
 
B

Bob Phillips

Something like this?

Sub ChangePassword()
Dim Line As String
Dim i As Long

With Application.VBE.ActiveVBProject.VBComponents("Module1").CodeModule

For i = 1 To .CountOfLines

Line = .Lines(i, 1)
If Left$(Line, 16) = "Global Const PWD" Then

.ReplaceLine i, "Global Const PWD As String = ""new_pwd"""
End If
Next i
End With
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top