需要访问VBA类似于给定的Excel VBA [英] Need Access VBA similar to the given Excel VBA

查看:81
本文介绍了需要访问VBA类似于给定的Excel VBA的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,以下Excel VBA代码用于通过双击与该行对应的第一列中的单元格来选择5行。代码在excel中运行良好。


但是,我需要Access VBA代码,它打开excel文件并执行相同的功能。


有谁能建议我怎么做?提前致谢!

Hi, the following Excel VBA code is used to select 5 rows by double clicking the cell in the first column corresponding to that row. The code is working fine in excel.

But, I need Access VBA code, which opens the excel file and performs the same function.

Can anyone suggest me how to do this? Thanks in advance!

展开 | 选择 | Wrap | 行号

推荐答案

您的Excel代码在MS Access中应该可以正常工作只要你:

1.在MS Access的Visual Basic编辑器中设置对Excel对象库的引用。

2.使用excel自动化代码打开你的工作簿在调用函数之前访问ms(参见下面的代码)。


设置引用,

打开Access VBE(ALT + F11 )

转到工具|参考资料

选中旁边的复选框相关的Excel库(例如,如果使用Office 2000,则为Microsoft Excel 9.0对象库)

单击确定


Your Excel code should work fine in MS Access provided that you:
1. set a reference to the Excel Object Library in the Visual Basic Editor in MS Access.
2. use excel automation code to open your workbook from ms access (see code below) before you call your function.

To set a reference,

Open the Access VBE (ALT + F11)
Go to Tools|References
Check the box next to the relevant Excel Library (for example Microsoft Excel 9.0 Object Library if using Office 2000)
Click OK


展开 | 选择 | <跨度类= codeDivider> | <跨度类= codeLink 的onclick = LineNumbers(本);>行号



您的Excel代码在MS Access中应该可以正常工作,前提是您:

1.设置参考到MS Access中的Visual Basic编辑器中的Excel对象库。

2.在调用函数之前,使用Excel自动化代码从ms访问(请参阅下面的代码)打开工作簿。


设置一个参考,


打开Access VBE(ALT + F11)

转到工具|参考资料

选中旁边的框相关的Excel库(例如,如果使用Office 2000,则为Microsoft Excel 9.0对象库)

单击确定


Your Excel code should work fine in MS Access provided that you:
1. set a reference to the Excel Object Library in the Visual Basic Editor in MS Access.
2. use excel automation code to open your workbook from ms access (see code below) before you call your function.

To set a reference,

Open the Access VBE (ALT + F11)
Go to Tools|References
Check the box next to the relevant Excel Library (for example Microsoft Excel 9.0 Object Library if using Office 2000)
Click OK


<跨度类= codeLink 的onclick = 模糊(此,this.parentNode.parentNode,的getChildren(本),TRUE);>展开 <跨度类=codeDivider > | 选择 | Wrap | 行号


当你说代码没有运行时,你需要提供一些细节。你有任何编译或运行时错误?如果答案是肯定的,那么错误消息是什么以及错误突出显示了哪些代码行?如果您不知道如何让代码编辑器突出显示错误行,请按以下步骤操作:转到VB代码编辑器的命令菜单,然后选择工具>选项>常规选项卡>选中标记中断所有错误确保在完成调试后将其更改为中断未处理的错误。

如果您没有收到任何错误,但程序未执行,则问题可能出在与Microsoft在2003年实施的沙盒安全性默认值相关的安全问题。要修复,请转到Access(而不是VB)命令菜单,并将宏安全级别设置为低。
When you say the code doesn''t run, you need to provide some details. Do you get any compile or runtime errors? If the answer is yes, what is the error message and what lines of code are highlighted for the error? In case you don''t know how to get the Code editor to highlight the error line, here''s how: Go to the command menu for the VB code editor and select Tools>options>general tab>checkmark "break on all errors". Be sure to change it back to"break on unhandled errors when you are finished debugging.

If you don''t get any errors, but program does not execute, your problem could be a security issue related to the sandbox security defaults implemented by Microsoft in 2003. To fix, go to the Access (not VB) command menu, and set your macro security level to low.


这篇关于需要访问VBA类似于给定的Excel VBA的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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