从 C++ 创建 Microsoft Word 文档 在 Visual Studio 2005 中

发布于 2024-07-25 04:19:03 字数 210 浏览 5 评论 0原文

我们的家庭作业是使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

晨与橙与城 2024-08-01 04:19:04

您可以使用 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

月竹挽风 2024-08-01 04:19:03

查看从 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文