CLR C++ Set Word CustomDocumentProperties
2024-09-12 15:24:04
- // WordIssue.cpp : main project file.
- #include "stdafx.h"
- using namespace System;
- using namespace System::Reflection;
- #define Office Microsoft::Office
- #define Word Office::Interop::Word
- #define Core Office::Core
- int main(array<System::String ^> ^args)
- {
- Word::Application^ wdApp = gcnew Word::Application();
- wdApp->Visible = true;
- Object^ missing = Type::Missing;
- String^% FileName =
- gcnew String("C:\\Users\\v-yangxu\\Desktop\\Work\\1212030001.docx");
- Boolean^% flag = gcnew Boolean(false);
- Object^ m = Type::Missing;
- Word::Document^ wdDoc = wdApp->Documents->Open(FileName,m,flag,m,m,m,m,m,
- m,m,m,m,m,m,m,m);
- Object^ cps = wdDoc->GetType()->InvokeMember("CustomDocumentProperties",
- BindingFlags::Default | BindingFlags::GetProperty,
- nullptr,wdDoc,nullptr);
- Type^ type = cps->GetType();
- array<Object^>^ oargs = {"MyAttribute",false,
- Core::MsoDocProperties::msoPropertyTypeString,"Just a test"};
- try{
- type->InvokeMember("Add",
- BindingFlags::Default | BindingFlags::InvokeMethod, nullptr,
- cps, oargs );
- }catch(Exception^ ex){
- Console::WriteLine(ex->Message);
- }
- Console::ReadKey();
- return 0;
- }
最新文章
- 编译器开发系列--Ocelot语言7.中间代码
- linux命令每日一练习-tail
- python 之select
- SQLite Expert 删除表数据并重置自动增长列
- Java学习总结(二)----Java语言基础
- 机器学习基石--学习笔记01--linear hard SVM
- Hive cli源码阅读和梳理
- SqlServer数据库的查询优化
- SQL跨数据库复制表数据
- linux下centos安装android sdk最新全面教程【可行】
- html5标签placeholder使用
- Linux下PHP与普通C程序通信
- Java静态代理和动态代理
- win10 永久激活 命令行方式
- Firefox扩展安装
- 记录eclipse安装SpringBoot插件及搭建SpringBoot项目
- 2018-CVTE中央研究院-自然语言处理算法工程师-电话初面问题
- STL之pair对组
- js 数组操作函数有:push,pop,join,shift,unshift,slice,splice,concat
- JavaScript 如何从引用类型(Array 、 Object)创建一个新的对象
热门文章
- 文件服务&mdash;&mdash;Vsftpd
- Javascript中的迭代、归并方法
- std::string和int类型的相互转换(C/C++)
- margin系列之keyword auto
- Control character in cookie value, consider BASE64 encoding your value , java操作cookie遇到中文会报错的解决方案
- 不能将“const char [7]”转换为“LPCTSTR”
- (转载)Delphi TStringList的用法
- 用 BPL 封装数据连接
- Linux下GPIO驱动(五) ----misc_register();
- 【BZOJ】1001: [BeiJing2006]狼抓兔子 Dinic算法求解平面图对偶图-最小割