Qt调用word 例子
Qt调用word 例子
Getting Microsoft Word Object to SaveAs
- #include <QtGui>
- #include <QAxObject>
- #include <QAxWidget>
- int main(int argc, char **argv)
- {
- QApplication a(argc, argv);
- QAxWidget word("Word.Application");
- word.setProperty("Visible", true);
- QAxObject * documents = word.querySubObject("Documents");
- documents->dynamicCall("Add (void)");
- QAxObject * document = word.querySubObject("ActiveDocument");
- document->dynamicCall("SaveAs (const QString&)", QString("e:/test/docbyqt.doc"));
- document->dynamicCall("Close (boolean)", false);
- word.dynamicCall("Quit (void)");
- return 0;
- }
Getting Microsoft Word Object to SaveAs
- //Start Word
- my_app = new QAxObject("Word.Application", this);
- QAxObject* my_docs = my_app->querySubObject("Documents");
- //Open newDocName
- QVariant filename(newDocName);
- QVariant confirmconversions(false);
- QVariant readonly(false);
- QVariant addtorecentfiles(false);
- QVariant passworddocument("");
- QVariant passwordtemplate("");
- QVariant revert(false);
- QAxObject* doc = my_docs->querySubObject("Open(const QVariant&, const QVariant&,const QVariant&, const QVariant&, const QVariant&, const QVariant&,const QVariant&)", filename,confirmconversions, readonly, addtorecentfiles, passworddocument, passwordtemplate, revert);
- //Pull out active document object
- QAxObject* active_doc = my_app->querySubObject("ActiveDocument");
- QVariant newFileName(fileNameString);
- QVariant fileFormat(10); //Saving as filtered html
- QVariant LockComments(false);
- QVariant Password("");
- QVariant recent(true);
- QVariant writePassword("");
- QVariant ReadOnlyRecommended(false);
- active_doc->querySubObject("SaveAs(const QVariant&, const QVariant&,const QVariant&, const QVariant&, const QVariant&, const QVariant&,const QVariant&)", newFileName, fileFormat, LockComments, Password, recent, writePassword, ReadOnlyRecommended);
Qt调用word 例子的更多相关文章
- 安卓环境下,通过QT调用jar包
在安卓上,许多第三方工具都提供jar包.qt可以通过jni来调用jar包.本文通过一个例子,说明安卓上QT调用jar的方式. 工具/原料 qt android jar包 jar包准备 1 ja ...
- 通过QT查找Word中的关键字,并做高亮或删除操作
最近由于项目需要,要用QT操作Word文档.具体的工作需求:在指定的Word文档(*.doc文件/*.docx文件)中查找关键字,找到后做高亮操作或者直接删除操作,然后另存为到别的目录(表示这个文件被 ...
- QT 调用VS2015编写的Dll
最近在用QT调用VC生成的库,QT使用的是MinGW调试器,出现与动态库不兼容的问题,最后发现QT只能识别VC生成的C格式下的动态库 也就是在导入导出设置时加入extern "C" ...
- Qt调用Server SQL中的存储过程
Server SQL中的存储过程如下: CREATE procedure PINSERTPC @pcnum int, @pcname varchar(50), @pctype int, @ipaddr ...
- Qt调用WebService
从网上查找Qt调用WebService的方案,需要下载三方的类库,而且需要使用好几个控制台命令,才能生成代理客户端类.因为只是简单的测试,没有采用这种方式,直接使用HTTP的Get获取网站内容,也非常 ...
- 服务器端调用Word组件读取Word权限、未将对象引用到对象实例终极解决方案
最近因为业务需要,需要在服务器上调用Word组件,结果遇到各种问题,比如检索 COM 类工厂中 CLSID 为 {000209FF-0000-0000-C000-000000000046} 的组件失败 ...
- c# 异步调用简单例子(转载)
首先来看一个简单的例子: 小明在烧水,等水烧开以后,将开水灌入热水瓶,然后开始整理家务 小文在烧水,在烧水的过程中整理家务,等水烧开以后,放下手中的家务活,将开水灌入热水瓶,然后继续整理家务 这也是日 ...
- Qt打开外部程序和文件夹需要注意的细节(Qt调用VC写的动态库,VC需要用C的方式输出函数,否则MinGW32编译过程会报错)
下午写程序中遇到几个小细节,需要在这里记录一下. ? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 QProcess *process = new QProcess(this ...
- Qt 向word中插入文字(使用QAxWidget和QAxObject)
pro 文件中要加入 CONFIG += qaxcontainer 2. main.cpp #include <QApplication> #include <QAxWidget&g ...
随机推荐
- Android手势识别(单击 双击 抬起 短按 长按 滚动 滑动)
对于触摸屏,其原生的消息无非按下.抬起.移动这几种,我们只需要简单重载onTouch或者设置触摸侦听器setOnTouchListener即可进行处理.不过,为了提高我们的APP的用户体验,有时候我们 ...
- nyoj 55 懒省事的小明 优先队列 multiset 还有暴力
懒省事的小明 时间限制: 3000 ms | 内存限制: 65535 KB 难度: 3 描述 小明很想吃果子,正好果园果子熟了.在果园里,小明已经将所有的果子打了下来,而且按果子的 ...
- 使用commons-daemon启动、关闭java程序
系统环境: CentOS 7 X64 JDK1.8 一: 安装jsvc 下载 commons-daemon的源代码包 http://apache.fayea.com//commons/daemon/s ...
- Office 2013 正式版 下载地址 带正版验证
万众期待的正式版Office 2013 降临---英文版/中文简体版 英文版软件下载地址: office_professional_plus_2013_x86_dvd en_office_profes ...
- H面试程序(4):翻转句子中单词的顺序 .
题目:输入一个英文句子,翻转句子中单词的顺序,但单词内字符的顺序不变. 句子中单词以空格符隔开.为简单起见,标点符号和普通字母一样处理. 例如输入“I am a student.”,则输出“stude ...
- Swift - 复杂数据类型说明(数组,字典,结构体,枚举)
1,数组 - Array 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 var types ...
- Delphi中WebBrowser自动填表模板
unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, ...
- boost 的函数式编程库 Phoenix入门学习
这篇文章是我学习boost phoenix的总结. 序言 Phoenix是一个C++的函数式编程(function programming)库.Phoenix的函数式编程是构建在函数对象上的.因此,了 ...
- [Usaco2008 Dec]Patting Heads
It's Bessie's birthday and time for party games! Bessie has instructed the N (1 <= N <= 100,00 ...
- Chrome App远程控制
現在google app連上chrome就能遠控了出了幾年了, 能用觸控控制mouse https://chrome.google.com/webstore/detail/chrome-remote- ...