ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Global Const for password (https://www.excelbanter.com/excel-programming/422665-global-const-password.html)

eggpap[_12_]

Global Const for password
 

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 all
the wb sheets. Now I'ld like to create a macro to change the password
periodically. My question is: is it possible to re-declare PWORD
programmatically without using a file to store its value? Or, in other
words, how you'ld do?

Emiliano


--
eggpap

Excel 2003 on Vista HP System - can use VBA
------------------------------------------------------------------------
eggpap's Profile: http://www.thecodecage.com/forumz/member.php?userid=90
View this thread: http://www.thecodecage.com/forumz/sh...ad.php?t=52031


Bob Phillips[_3_]

Global Const for password
 
Something like this?

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

With Application.VBE.ActiveVBProject.VBComponents("Modu le1").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


--
__________________________________
HTH

Bob

"eggpap" wrote in message
...

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 all
the wb sheets. Now I'ld like to create a macro to change the password
periodically. My question is: is it possible to re-declare PWORD
programmatically without using a file to store its value? Or, in other
words, how you'ld do?

Emiliano


--
eggpap

Excel 2003 on Vista HP System - can use VBA
------------------------------------------------------------------------
eggpap's Profile: http://www.thecodecage.com/forumz/member.php?userid=90
View this thread: http://www.thecodecage.com/forumz/sh...ad.php?t=52031




eggpap[_13_]

Global Const for password
 

Many Thanks, I will try!


--
eggpap

Excel 2003 on Vista HP System - can use VBA
------------------------------------------------------------------------
eggpap's Profile: http://www.thecodecage.com/forumz/member.php?userid=90
View this thread: http://www.thecodecage.com/forumz/sh...ad.php?t=52031



All times are GMT +1. The time now is 04:14 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com