Excel VBA-自动输入密码 [英] Excel VBA - Automatically Input Password

查看:1127
本文介绍了Excel VBA-自动输入密码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想编写一个Excel VBA宏来自动为用户输入密码.这样,用户无需在每次双击文件时手动输入密码.这可能吗?如果是这样,我该怎么办?

I want to write an Excel VBA macro to input the password automatically for the user. That way, the user does not need to input the password manually every time they double click on the file. Is this possible? If so, how can I do this?

推荐答案

正如我的评论中所提到的,我认为您无法实现所寻求的功能.让我解释一下.

As mentioned in my comment, the functionality that you seek, in my opinion cannot be done. Let me explain it.

要在Excel文件中自动运行VBA代码,您需要将代码放置在ThisWorkbook代码区域的Workbook_Open()或模块的Auto_Open()中.

To auto run a VBA code in an Excel file you need to place the code either in the Workbook_Open() in the ThisWorkbook code area or in Auto_Open() in a module.

现在,这两个Sub仅在将密码输入到受密码保护的文件中之后(即在打开工作簿之后)才执行.因此,在将密码输入密码对话框或打开工作簿之前,无法运行此方法.

Now these two Subs execute only after the password has been entered in a password protected file i.e after the workbook has opened. So there is no way this can be run before the password is fed to the password dialog box or before the Workbook is opened.

我确定你的老板是个明智的人,如果你能向他很好地解释,他会明白的:)

I am sure your boss is a sensible guy and will understand if you can explain it nicely to him :)

您可能还希望看到此链接,其中详细说明了有关自动运行宏的详细信息.

You might also want to see this link which explains more in details about running the macro automatically.

主题:在Excel启动时运行宏

Topic: Running a macro when Excel starts

链接: 从以上链接引用

如果要在每次启动Microsoft Excel时自动执行某些操作,则可以记录或编写在打开工作簿时将运行的宏.有两种方法可以做到这一点:

If you want to automatically perform certain actions whenever you start Microsoft Excel, you can record or write a macro that will run whenever you open a workbook. There are two ways to do this:

记录一个宏,并使用名称Auto_Open保存它. 将宏作为Microsoft VisualBasic®for Applications(VBA)过程编写,以用于工作簿的Open事件.

Record a macro and save it using the name Auto_Open. Write the macro as a Microsoft Visual Basic® for Applications (VBA) procedure for the Open event of a workbook.

这篇关于Excel VBA-自动输入密码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆