Excel20 10vba encryption method

In Excel, in addition to setting, you can also use VBA programming for encryption. Using VBA programming can make encryption more strict. The following is the encryption method of excel20 10 vba that I shared, I hope it will be useful to you.

Excel20 10 vba encryption method uses vba encryption step 1: For developers who want to publish their own Excel VBA, Excel VBA itself does not provide VBA code encryption and encapsulation. At present, the most reliable encryption method of Excel VBA code is to compile VBA code into DLL (dynamic link library file) and call it in VBA, so as to realize the encryption package of VBA code and facilitate the integration and release with Excel file. DLL files are difficult to crack, while other VBA encryption methods are easy to crack. Users only need your Excel file and this dll file, and do not need to install any other programs.

Encrypting with VBA Step 2: Compiling into a DLL file is actually very simple. You can compile a dll file by installing Visual Basic 6.0 on your computer, but Visual Basic. Net is in trouble. Visual Basic calls Excel and its objects through OLE (object link engine) technology.

The third step of using VBA encryption: Generally speaking, VBA code only needs some simple modifications. Mainly refers to Excel objects, otherwise VB can't identify the objects in vba code. For example, the following VBA code

Windows (workbook 1). Make active

Range ("L50")= 1

Putting it directly into VB and compiling it into Dll will have problems, because VB can't directly identify the range object.

You need to add a few simple lines of code to tell vb how to refer to these objects in excel:

Dim xlapp as excel.applicatiion

Mark xlbook as excel.workbook

Mark xlsheet as excel.worksheet

set xlapp=getobject(," excel.application)

set xlbook=getobject(xxx)

set XL sheet = XL book . worksheets( 1)

Encrypt with vba Step 4: Then copy your original VBA code, but add an object reference in front:

xlsheet.range("L50")= 1

The fifth step of using VBA encryption: modify VBA code in this way and debug it in VB, so that multiple subprograms can be successfully compiled and encapsulated in a DLL file. In the future, directly refer to each sub subroutine in VBA DLL file. Initially, most of VBA code is encapsulated in DLL files, which is invisible to users.

Using VBA encryption Step 6: Developers can also display the copyright information of the software and set a password before the program runs. Because these are also encapsulated in DLL files, users can't crack them.

How to control the length of each column of data in EXCEL and avoid entering 1 repeatedly, and define the data length by data validity?

Select the data range to be entered with the mouse, and then click Data->; "effectiveness"->; Settings and validity conditions are Allow and Text Length is equal to 5 (the specific conditions can be changed according to your needs).

You can also define some prompt information, error warning information and whether to open the Chinese input method. Click OK after definition.

2. Use conditional formatting to avoid duplication.

Select column a and click format->; "Conditional format", set the condition as? Formula =COUNTIF($A:$A,$A 1)> 1? , click "format"->; "font"->; "Color", select red, and click "OK" twice.

After this setting, if the input data is wrong in length, there will be a prompt, and if the data is repeated, the font will turn red.