vb中运行vba代码_自动在VBA和VB6代码中插入过程名称

本文介绍了一款VB6和VBA的加载项,它能自动在代码中添加`Debug.Print`语句,以方便调试时查看执行过程。加载项通过在IDE中增加工具栏,允许用户选择要修改的过程。安装加载项涉及重命名并注册DLL文件,然后在VB6或Excel VBE中启用。
摘要由CSDN通过智能技术生成

vb中运行vba代码

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't interested in and/or not all of the procedures that led up to arriving at the break point. Adding

当试图找出VBA或VB6中的问题的原因时,了解在错误发生之前执行了哪些过程通常很有价值。 您可以为此使用调用堆栈,但是它通常不足,因为它可能显示您不感兴趣的过程和/或不是导致到达断点的所有过程。 新增中

Debug.Print statements or MsgBox statements in procedures is another way but adding them manually can be very tedious. The add-in I've attached resolves those problems by automatically adding  statements in all selected procedures that contains "Debug.Print" or whatever else you want along with the name of the procedure. 

过程中的Debug.Print语句或MsgBox语句是另一种方法,但是手动添加它们可能非常繁琐。 我随附的外接程序通过自动添加来解决这些问题 所有选定过程中包含“ Debug.Print”或任何其他所需语句以及过程名称的语句。

When the add-in is loaded this toolbar will be added to the Visual Basic IDE in VB6 or the VBE (Visual Basic Environment) in Excel.

加载加载项后,此工具栏将被添加到VB6中的Visual Basic IDE或Excel中的VBE(Visual Basic环境)中。

Insert-Procedure-Names-Toolbar.jpg
Choose-Code.jpg

And this shows the VB6 version of the window that appears if you click the first button in the toolbar. You use it to select the procedures to be modified. (The VBA version uses different icons which match those that are used in Excel.) In this case shown below all the procedures in frmMain will have the statements added to them but I could have chosen any or all procedures in any or all modules. Had the statements been previously added, the 'Remove' button would have been enabled and clicking it would remove the added statements from your program.

这显示了您单击工具栏中的第一个按钮时出现的窗口的VB6版本。 您可以使用它来选择要修改的过程。 (VBA版本使用与Excel中使用的图标相匹配的不同图标。)在这种情况下,如下所示,frmMain中的所有过程都将添加语句,但是我可以在任何或所有模块中选择任何或所有过程。 如果先前已添加语句,则将已启用“删除”按钮,单击该按钮将从程序中删除添加的语句。

Insert-Procedures-VB6.jpg

Installing the Add-Ins

安装加载项

VB6 VB6

Download the InsertProcNameVB6.txt attachment and change the name to InsertProcNameVB6.dll. It doesn't matter where you store it. Once you have the file renamed you need to register the dll. To do that go to Start|Run and enter regsvr32 C:\InsertProcNameVB6.dll on the 'Open:' line and press OK. You should get a message saying that the registration was successful.

下载InsertProcNameVB6.txt附件,并将名称更改为InsertProcNameVB6。 dll文件 。 存放在哪里都无所谓。 将文件重命名后,您需要注册dll。 为此,请转到“开始” |“运行”,然后在“打开:”行上输入

InsertProcNameVB6.txt InsertProcNameVB6.txt

The final step is to go to the VB6 IDE and select the Add-Ins|Add-In Manager… menu item and select 'Insert Procedure Names VB6' from the list. Under 'Load Behavior' I suggest selecting both available options.

最后一步是转到VB6 IDE,然后选择“

Excel 电子表格

Download the InsertProcNameVBA.txt attachment and change the name to InsertProcNameVBA.dll. It doesn't matter where you store it. Once you have the file renamed you need to register the dll. To do that go to Start|Run and enter regsvr32 C:\InsertProcNameVBA.dll on the 'Open:' line and press OK. You should get a message saying that the registration was successful.

下载InsertProcNameVBA.txt附件,并将名称更改为InsertProcNameVBA。 dll文件 。 存放在哪里都无所谓。 将文件重命名后,您需要注册dll。 为此,请转到“开始” |“运行”,

InsertProcNameVBA.txt InsertProcNameVBA.txt

The final step is to go to the Excel VBE and select the Add-Ins|Add-In Manager… menu item and select 'Insert Procedure Names VBA' from the list. Under 'Load Behavior' I suggest selecting both available options.

最后一步是转到Excel VBE,然后选择“

Note that while this is a COM add-in you won't see it listed if you go to either File|Options|Add-Ins|COM Add-Ins (or Excel Add-ins).

请注意,尽管这是一个COM加载项,但是如果您转到File | Options | Add-Ins | COM加载项(或Excel加载项),则不会看到它的列出。

If you are interested in learning more about debugging VBA or VB6 code then see my Using the VB6 Debugger tutorial.

如果您想了解有关调试VBA或VB6代码的更多信息,请参阅我的使用VB6调试器教程。

Finally, if you find that this article has been helpful, please click the “thumb’s up” button below. Doing so lets me know what is valuable for EE members and provides direction for future articles. It also provides me with positive feedback in the form of a few points. Thanks!

最后,如果您发现本文对您有所帮助,请单击下面的“竖起大拇指”按钮。 这样做可以让我知道对EE成员有价值的内容,并为以后的文章提供指导。 它还以几点的形式为我提供了积极的反馈。 谢谢!

翻译自: https://www.experts-exchange.com/articles/8634/Automatic-Insertion-of-Procedure-Names-in-VBA-and-VB6-Code.html

vb中运行vba代码

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值