从 C++ 创建 Microsoft Word 文档 在 Visual Studio 2005 中
我们的家庭作业是使用 Visual Studio 2005 和 C++ 创建 Microsoft Word 文档。 谁能解释一下这是如何做到的。 我试图使用 VSTO 来做到这一点,但我没有运气。 我可以找到的互联网上的所有资源都解释了如何在 VB 或 C# 中完成此操作,但我需要一些 C++ 示例。 谢谢
编辑:接受的格式是.doc。
We got a homework assignment to create a Microsoft Word document using Visual Studio 2005 and C++. Could anyone explain how this could be done. I was trying to do it using VSTO, but I've had no luck. All resources on the internet I could find explain how this could be done in VB or C#, but I need some C++ examples.
Thanks
EDIT: Accepted format is .doc.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
显然 VSTO 不适用于 C++。
此 MSDN 文章有帮助吗?:
Apparently VSTO is not available for C++.
Does this MSDN article help?:
您可以使用 Mircosoft Office 的主互操作程序集来完成此操作。 使用 C++ 执行此操作并不像看起来那么困难。 您需要从项目属性中打开公共语言运行时支持,然后只需在 Mircosoft.Office.Interop.dll 上执行
#using 语句
即可。之后,您应该可以根据需要使用互操作程序集。 在 C++ 中,您访问 .NET 类的方式略有不同,即替换 . 与 :: 类似...
Microsoft::Office::Interop::Word^ wordObj = new Microsoft::Office::Interop::Word();
Microsoft Office 2003 PIA
Microsoft Office 2007 PIA
You can do this using Mircosoft Office's Primary Interop Assemblies. Doing this with C++ is not as difficult as it seems. you need to turn on Common Language Runtime support from project properties and then you can simply do a
#using statement
on the Mircosoft.Office.Interop.dll.After that you should be OK to use the interop assembly as you want. In C++, you access .NET classes a little different i.e., replacing . with :: Something like...
Microsoft::Office::Interop::Word^ wordObj = new Microsoft::Office::Interop::Word();
Microsoft Office 2003 PIAs
Microsoft Office 2007 PIAs
以下是二进制 Word 文档格式的规范。 您可以轻松地推出自己的实现。
http://www.microsoft.com/interop/docs/OfficeBinaryFormats.mspx
Here is a spec of the binary Word document format. You could easily roll your own implementation.
http://www.microsoft.com/interop/docs/OfficeBinaryFormats.mspx
查看从 C 应用程序而不是 C++ 使用 OLE 自动化。 这将向您展示访问 Word 的 OLE 自动化界面的简单方法。
对于方法、属性,请使用“对象浏览器”,您可以通过选择“工具”->“对象浏览器”来访问它。 宏-> Visual Basic 编辑器。 按
F2
调用对象浏览器。Take a look at Use OLE Automation from a C Application Rather Than C++. That will show you the plain way to access the OLE automation interface for Word.
For methods, properties, use the Object Browser which you can access by selecting Tools -> Macro -> Visual Basic Editor. Press
F2
to invoke the object browser.