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. }

最新文章

  1. 编译器开发系列--Ocelot语言7.中间代码
  2. linux命令每日一练习-tail
  3. python 之select
  4. SQLite Expert 删除表数据并重置自动增长列
  5. Java学习总结(二)----Java语言基础
  6. 机器学习基石--学习笔记01--linear hard SVM
  7. Hive cli源码阅读和梳理
  8. SqlServer数据库的查询优化
  9. SQL跨数据库复制表数据
  10. linux下centos安装android sdk最新全面教程【可行】
  11. html5标签placeholder使用
  12. Linux下PHP与普通C程序通信
  13. Java静态代理和动态代理
  14. win10 永久激活 命令行方式
  15. Firefox扩展安装
  16. 记录eclipse安装SpringBoot插件及搭建SpringBoot项目
  17. 2018-CVTE中央研究院-自然语言处理算法工程师-电话初面问题
  18. STL之pair对组
  19. js 数组操作函数有:push,pop,join,shift,unshift,slice,splice,concat
  20. JavaScript 如何从引用类型(Array 、 Object)创建一个新的对象

热门文章

  1. 文件服务&mdash;&mdash;Vsftpd
  2. Javascript中的迭代、归并方法
  3. std::string和int类型的相互转换(C/C++)
  4. margin系列之keyword auto
  5. Control character in cookie value, consider BASE64 encoding your value , java操作cookie遇到中文会报错的解决方案
  6. 不能将“const char [7]”转换为“LPCTSTR”
  7. (转载)Delphi TStringList的用法
  8. 用 BPL 封装数据连接
  9. Linux下GPIO驱动(五) ----misc_register();
  10. 【BZOJ】1001: [BeiJing2006]狼抓兔子 Dinic算法求解平面图对偶图-最小割