在 VB.NET 中使用 Office Interop for Word 和 Outlook 2007
我需要在程序中进行互操作,以自动执行 Word 和 Outlook 中的多个功能。 有谁知道一个好的起点。 我的目标是启动邮件合并,创建几个不同的文件并相应地保存它们,然后根据谁的需要将不同的文件通过电子邮件发送给不同的人。 任何学习如何正确使用互操作的帮助将不胜感激。
我目前使用 Visual Studio 2008 和 Office 2007 并使用 vb.net 编写程序。
I need interop in my programs to automate several functions in Word and Outlook. Does anyone know a good place to start. My goal is to kick off a mail merge, create several different files and save them accordingly, then e-mail the different files to different people based upon who needs what. Any help learning how to use the interop properly would be greatly appreciated.
I am currently using Visual Studio 2008 and Office 2007 and use vb.net to write my programs.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
一个好的入门方法是使用宏编辑器记录您尝试执行的步骤。 您可以获取生成的宏代码并根据您的目的进行修改。 单击您不知道其用途的函数和变量的名称,然后按“F1”以获得上下文特定的帮助。
A good way to get started is to use the macro editor to record the steps you are trying to perform. You can take the generated macro code and modify it for your purposes to suit. Click on the names of functions and variables of which you do not know the purpose and hit "F1" to get context specific help.
将 COM 引用添加到 Outlook 12.0 对象库和 Word 12.0 对象库。
这个网页确实帮助我开始:http://support.microsoft.com/kb/316383
然后,通过录制宏,您将公开许多您可能想要使用的内容。 然而,需要警告的是,并非 VBA(宏)中公开的所有内容都可以在 VB .NET 中访问。 我不知道为什么会这样,但实际上我必须在 Excel 中从 VB.NET 构建并执行一个用 VBA 编写的宏,才能完成一些看起来非常简单的事情,如果不是因为二。
有关邮件合并的一些好信息:http://support.microsoft.com/kb/258512
以下文章提供了一些帮助您启动并连接 Outlook Interop 的基本步骤: http://support.microsoft .com/kb/313787
希望这有帮助。 我会留意您在这里提出的问题——我想说我在互操作方面了解很多。
Add COM references to Outlook 12.0 Object library and Word 12.0 Object library.
This web page really helped kick me off: http://support.microsoft.com/kb/316383
Then, by recording macros you'll expose a lot of the stuff you'll likely want to work with. Word of warning, however, is that not everything exposed in VBA (macros) is accessible within VB .NET. I don't know why this is, but I've actually had to construct and execute a macro from VB.NET, written in VBA, within Excel to accomplish something that seemed ridiculously easy if it weren't for the strange disconnect between the two.
Some good info on Mail Merge: http://support.microsoft.com/kb/258512
Here's an article with some basic steps to get you up and connected with Outlook's Interop: http://support.microsoft.com/kb/313787
Hope this helps. I'll keep an eye out for questions from you here--I'd say I know quite a bit when it comes to interop.
您可能想从这里开始: http://msdn.microsoft.com/en -us/office/bb266408.aspx。
有很多教程。
You might want to start here: http://msdn.microsoft.com/en-us/office/bb266408.aspx.
There are a number of tutorials.