qt调用office得com组件将word另存为html格式

这篇博客介绍了如何利用Qt的QAxWidget组件调用Office的COM接口,将.docx或.doc格式的Word文档另存为HTML格式。通过设置不同的属性,如文件名、保存格式和密码,实现了文档的无显示转换,并展示了相关的代码实现。
摘要由CSDN通过智能技术生成

      #include <QAxWidget> 

 

       QAxWidget *a = new QAxWidget("Word.Application");//打开Word 
        a->setControl(g_strSrcFilePath);//打开此Word文档 
        a->setProperty("Visible",false);//设置程序不显示 
        QVariant newFileName; 
        if (g_strSrcFilePath.endsWith(".docx"))
        { 
            newFileName.setValue(g_strSrcFilePath.left(g_strSrcFilePath.size() - 5).append(".html"));
        }
        else if (g_strSrcFilePath.endsWith(".doc")){
            newFileName.setValue(g_strSrcFilePath.left(g_strSrcFilePath.size() - 4).append(".html"));
        }
        QVariant fileFormat(10); //文件保存格式 HTML文件 这个值有几个枚举类型具体参考:WdSaveFormat枚举
        QVariant LockComments(false);//注释 
        QVariant Password("");//设置打开密码 
        QVariant recent(false);//最近打开的文件 
        QVariant writePassword(""

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值