简体   繁体   English

在其他VBA项目中的Excel加载项中隐藏工作表

[英]Hide worksheet in Excel Add-In from other VBA Projects

I have an Excel Add-In which I am building which stores users settings in a Settings worksheet within the Add-In. 我正在构建一个Excel加载项,它将用户设置存储在该加载项的Settings工作表中。 I use the Settings sheet essentially as storage for boolean values and potentially, the user's registration details. 我本质上使用“ Settings表来存储布尔值以及潜在地存储用户的注册详细信息。

However, if I open up a new VBA Project and include the Add-In as a reference (In VBA: Tools > References > MY Add-In ) then I can access the Settings worksheet and potentially break the password on it and hack the registration details. 但是,如果我打开一个新的VBA项目并将该加载项作为参考(在VBA中: Tools > References > MY Add-In ),则可以访问“ Settings工作表,并可能破坏其密码并入侵注册细节。

The Settings sheet is set to be xlVeryHidden however it can be accessed via VBA code. Settings表设置为xlVeryHidden但是可以通过VBA代码访问。 Is there anyway to prevent this in Excel? 无论如何,在Excel中可以防止这种情况发生吗? In a module for example I can use the Option Private Module method. 例如,在模块中,我可以使用Option Private Module方法。

If you password protect and lock the project then your code and the worksheet objects can't be viewed. 如果使用密码保护和锁定项目,则无法查看您的代码和工作表对象。 Go to Tools > VBAObject properties > Protection tab then tick 'Lock Project For Viewing' and then set a password in 'Password to view object properties'. 转到“工具”>“ VBAObject属性”>“保护”选项卡,然后勾选“锁定要查看的项目”,然后在“密码以查看对象属性”中设置密码。

However, there is nothing to stop a hacker from... 但是,没有什么可以阻止黑客...

For s = 1 to Sheets.Count
   Sheets(s).visible = True
Next s

...to see your Settings sheet. ...以查看“设置”表。

There are a few options: 有几种选择:

1) Have the settings sheet in a seperate workbook, or some other format like .txt and read from that (recommended). 1)将设置表放在单独的工作簿中,或其他格式(例如.txt)中,并从中读取(推荐)。

2) Use some kind of encryption in your Setting sheet and decrypt it in your code, a really simple example is to use numbers in place of text so 'example' would = '5,24,1,13,16,12,5', but obviously you want to employ something more sophisticated that than and you can search online for many ways to do it. 2)在设定表中使用某种加密方式并在代码中对其进行解密,一个非常简单的示例是使用数字代替文本,因此“示例”应为'5,24,1,13,16,12,5 ”,但显然您想采用比这更复杂的方法,并且可以在线搜索许多方法来进行操作。

3) Use 2, but store the decryption code somewhere else. 3)使用2,但将解密代码存储在其他位置。

Be aware though, that for someone who knows what they're doing there really is no way to prevent a VBA hack , unless you use option 1/3 and have a way to store the file somewhere that isn't publicly accessible. 但是请注意,对于知道自己在做什么的人来说,实际上是无法阻止VBA hack的 ,除非您使用选项1/3并有办法将文件存储在无法公开访问的位置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM