1. // WordIssue.cpp : main project file.
  2. #include "stdafx.h"
  3. using namespace System;
  4. using namespace System::Reflection;
  5. #define Office Microsoft::Office
  6. #define Word Office::Interop::Word
  7. #define Core Office::Core
  8. int main(array<System::String ^> ^args)
  9. {
  10. Word::Application^ wdApp = gcnew Word::Application();
  11. wdApp->Visible = true;
  12. Object^ missing = Type::Missing;
  13. String^% FileName =
  14. gcnew String("C:\\Users\\v-yangxu\\Desktop\\Work\\1212030001.docx");
  15. Boolean^% flag = gcnew Boolean(false);
  16. Object^ m = Type::Missing;
  17. Word::Document^ wdDoc = wdApp->Documents->Open(FileName,m,flag,m,m,m,m,m,
  18. m,m,m,m,m,m,m,m);
  19. Object^ cps = wdDoc->GetType()->InvokeMember("CustomDocumentProperties",
  20. BindingFlags::Default | BindingFlags::GetProperty,
  21. nullptr,wdDoc,nullptr);
  22. Type^ type = cps->GetType();
  23. array<Object^>^ oargs = {"MyAttribute",false,
  24. Core::MsoDocProperties::msoPropertyTypeString,"Just a test"};
  25. try{
  26. type->InvokeMember("Add",
  27. BindingFlags::Default | BindingFlags::InvokeMethod, nullptr,
  28. cps, oargs );
  29. }catch(Exception^ ex){
  30. Console::WriteLine(ex->Message);
  31. }
  32. Console::ReadKey();
  33. return 0;
  34. }

CLR C++ Set Word CustomDocumentProperties的更多相关文章

  1. WinForm小白的WPF初试一:从PropertyGrid控件,输出内容到Word(上)

    学WinForm也就半年,然后转到WPF,还在熟悉中.最近拿到一个任务:从PropertyGrid控件,输出内容到Word.难点有: 一.PropertyGrid控件是WinForm控件,在WPF中并 ...

  2. .NET CLR 运行原理

    原文: Drill Into .NET Framework Internals to See How the CLR Creates Runtime Objects 文章讨论了: SystemDoma ...

  3. C# 操作 Word 修改word的高级属性中的自定义属性2

    word的类库使用的是word2007版本的类库,类库信息见下面图片,折腾了半天,终于找到入口,网上 很多说的添加或者修改word的高级属性中的自定义属性都是错误的,感觉都是在copy网上的代码,自己 ...

  4. C# 操作 Word 修改word的高级属性中的自定义属性

    为 Microsoft Word 创建自动化客户端 启动 Visual Studio .NET. 在文件菜单上,单击新建,然后单击项目.从 Visual C# 项目类型中选择 Windows 应用程序 ...

  5. jacob 操作word

    1. 首先下载jacob-1.18.zip,解压后有两个文件jacob.jar 和 jacob.dll.需要把jacob.jar放到你工程的classpath中并且把jacob.dll放到jdk的bi ...

  6. 深入探索.NET框架内部了解CLR如何创建运行时对象

    原文地址:http://msdn.microsoft.com/en-us/magazine/cc163791.aspx 原文发布日期: 9/19/2005 原文已经被 Microsoft 删除了,收集 ...

  7. C# 如何更改Word语言设置

    一般在创建或者打开一个Word文档时,如果没有进行过特殊设置的话,系统默认的输入语言的是英语输入,但是为适应不同的办公环境,我们其实是需要对文字嵌入的语言进行切换的,因此,本文将介绍如何使用免费版组件 ...

  8. VSTO:使用C#开发Excel、Word【14】

    操作workbooks集合可从Application对象的Workbooks属性中获取的Workbooks集合包含当前在应用程序中打开的Workbook对象的集合. 它还具有用于管理开放工作簿,创建新 ...

  9. [.NET开发] C# 如何更改Word语言设置

    一般在创建或者打开一个Word文档时,如果没有进行过特殊设置的话,系统默认的输入语言的是英语输入,但是为适应不同的办公环境,我们其实是需要对文字嵌入的语言进行切换的,因此,本文将介绍如何使用Spire ...

随机推荐

  1. [翻译][MVC 5 + EF 6] 5:Code First数据库迁移与程序部署

    原文:Code First Migrations and Deployment with the Entity Framework in an ASP.NET MVC Application 1.启用 ...

  2. jtemplate使用笔记

    最近的项目中用到了jtemplate, 它是客户端基于javascript的模板引擎,绑定的数据为json对象.以前我在页面上显示数据列表时最喜欢用Repeater控件了,因为它相对与其它几个服务端控 ...

  3. apache 工作模式

    apache三种工作模式: prefork(2.4前默认)/worker/event(2.4默认)内容整理来自以下网站http://m.blog.csdn.net/article/details?id ...

  4. Android AndroidManifest学习笔记

    <application>标签 : android:allowBackup="true" 数据可以备份 <activity>标签:configChanges ...

  5. JS 页面打印

    var hkey_root, hkey_path, hkey_key hkey_root = "HKEY_CURRENT_USER" hkey_path = "\\Sof ...

  6. java StringBuffer与StringBuilder

    StringBuffer:就是字符串缓冲区.         * 用于存储数据的容器.         * 特点:         * 1,长度的可变的.          * 2,可以存储不同类型数 ...

  7. jsoup 对网页中图片解析

    Elements article = new Elements(); Elements Img = new Elements(); article = doc.select("div#con ...

  8. nginx 常用的 URL 重写方法

    转自:http://www.jbxue.com/article/4727.html Nginx中一些常用的URL 重写方法介绍,有需要的朋友可以参考下.url重写应该不陌生,不管是SEO URL 伪静 ...

  9. 解决Genemotion 安装出现“Unable to start......”的问题

    最近在用uiautomator做安卓自动化测试,由于没有测试设备,所以只好自己在电脑里面安装了一个GenyMotion模拟器,虽然速度不及真机,但是也算能解决大部分的需求. 安装完之后启动出现了以下错 ...

  10. 【DB】SQLiteHelper

    /// <summary> /// 说明:这是一个针对System.Data.SQLite的数据库常规操作封装的通用类. /// </summary> public class ...