Creating a password for VBA project using a code

teranprasanna
Lounger
Posts: 27
Joined: 24 Jun 2020, 01:39

Creating a password for VBA project using a code

Post by teranprasanna »

Dear All,

Can we create a password for VBA project automatically, using a macro?

Appreciate your support on this,


Regards,
Teran

YasserKhalil
PlatinumLounger
Posts: 4913
Joined: 31 Aug 2016, 09:02

Re: Creating a password for VBA project using a code

Post by YasserKhalil »


User avatar
ChrisGreaves
PlutoniumLounger
Posts: 15613
Joined: 24 Jan 2010, 23:23
Location: brings.slot.perky

Re: Creating a password for VBA project using a code

Post by ChrisGreaves »

teranprasanna wrote:
21 Mar 2021, 02:39
Can we create a password for VBA project automatically, using a macro?
Teran, here are a few password-generation routines for variety (attached)
Cheers
Chris
You do not have the required permissions to view the files attached to this post.
There's nothing heavier than an empty water bottle

teranprasanna
Lounger
Posts: 27
Joined: 24 Jun 2020, 01:39

Re: Creating a password for VBA project using a code

Post by teranprasanna »

YasserKhalil wrote:
21 Mar 2021, 04:00
Have a look at this link
https://www.mrexcel.com/board/threads/l ... s.1136415/
Thanks for sharing..
I just copy the code from your link and change the workbook name, however error msg is showing as "Sub or Function not defined", How can i resolve this, thanks.

teranprasanna
Lounger
Posts: 27
Joined: 24 Jun 2020, 01:39

Re: Creating a password for VBA project using a code

Post by teranprasanna »

ChrisGreaves wrote:
21 Mar 2021, 10:54
teranprasanna wrote:
21 Mar 2021, 02:39
Can we create a password for VBA project automatically, using a macro?
Teran, here are a few password-generation routines for variety (attached)
Cheers
Chris
Thank you..
Can you please let me know which code can be used to my purpose, - To create a password for VBA Project.

User avatar
ChrisGreaves
PlutoniumLounger
Posts: 15613
Joined: 24 Jan 2010, 23:23
Location: brings.slot.perky

Re: Creating a password for VBA project using a code

Post by ChrisGreaves »

ChrisGreaves wrote:
21 Mar 2021, 10:54
Teran, here are a few password-generation routines for variety (attached)
Can you please let me know which code can be used to my purpose, - To create a password for VBA Project.
Teran, I believe that Yasser's link gives you the code you require, that of implementing an existing password to lock a VBA project.
I threw in the password-generation code as a bonus, and for any future readers of this thread.
Cheers
Chris
There's nothing heavier than an empty water bottle

jstevens
GoldLounger
Posts: 2628
Joined: 26 Jan 2010, 16:31
Location: Southern California

Re: Creating a password for VBA project using a code

Post by jstevens »

Chris,

I imported the file into Excel's VBAProject. In stepping through the code I see references back to WordBasic which is undefined in Excel VB.

Is there a handy WordBasic converter tool available?
Regards,
John

User avatar
ChrisGreaves
PlutoniumLounger
Posts: 15613
Joined: 24 Jan 2010, 23:23
Location: brings.slot.perky

Re: Creating a password for VBA project using a code

Post by ChrisGreaves »

Hello John.
Is there a handy WordBasic converter tool available?
Not in my system. Although I found a page here.

As far as I can see the call to a WordBasic function appears in only one of the attached functions, “strAppInfo” which as the name suggests delivers information about the application (in this case MSWord) in a string form. The comments to that function suggest this too: “Deliver useful Application information strings. Typical use - generating a somewhat unique key for the system.”
The four calls (within the loop) deliver

Code: Select all

'     651          Version 11.0 - Test Release, 5/30/07
'     652          beta version--built 5/30/07
'     653          PrimoPDF (winspool) on Ne00:
'     654          11.0.8169
and those text strings, I suggest, would vary somewhat between individual computer systems, even today, and so they would act as a local randomizing key, somewhat unique for each system.
In Word97 one would use the “System” attributes, and

Code: Select all

    Debug.Print System.OperatingSystem & Chr(32) & System.Version
    Debug.Print System.FreeDiskSpace
would deliver

Code: Select all

Windows NT 6.2
2147483647
with the second value changing, I would suggest, by the minute on most systems.
Where calls to the function “strAppInfo” are made, you will find us initializing a pseudo-random string generator.

The use of WordBasic suggests that I wrote some of these function before 1997, when Word 6.0 was all the rage, and that suggests that these function were part of a suite of functions that dealt with locked functions in WordBasic, and as such were part of a larger application-protection suite.

Thanks for bringing this to my attention. It is strange to think that my online banking and forum memberships are being protected in part by code that is more than a quarter-century old!
Cheers
Chris
There's nothing heavier than an empty water bottle