使用 VBA 从 Word 编辑 Excel 电子表格
如何使用 VBA 从 Word 编辑 Excel 电子表格?
How do I edit excel spreadsheets from word using VBA?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
如何使用 VBA 从 Word 编辑 Excel 电子表格?
How do I edit excel spreadsheets from word using VBA?
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(1)
首先,您需要设置对正在运行的 Excel 版本的引用。在 VBE 中,转到“工具”>“引用”,然后单击“Microsoft Excel 12.0 对象库”(2007 年为 12.0,2003 年为 11.0)等。
然后您可以编写类似这样的代码(打开 Excel 的新实例,打开、编辑和保存新工作簿) 。您可以使用 GetObject 访问正在运行的 Excel 实例:
First you need to set a reference to the version of Excel you are running. In the VBE go to Tools>References and click Microsoft Excel 12.0 Object Library (12.0 for 2007, 11.0 for 2003) etc.
Then you can code something like this (opens a new instance of Excel, opens, edits and saves a new workbook). You'd use GetObject to access a running instance of Excel: