如何打印一个word文档?在vc中实现,请教大家
你阅读MSDN(October2001)文章:Q184663 :UseMFCtoAutomateExcel&Create/FormataNewWorkbookQ186120 :CatchMicrosoftExcel97ApplicationEventsUsingVC++会对你有帮助。
如果要在你的程序中嵌入word等,可以使用htmlview实现。
================事实上也就是:启动Word进程,然后调用Application.word的打印功能。
word格式的文件怎么在VC中打开
C#中有微软提供的操作word的类库,我曾经使用过C++中应该也有的吧,如果没有官方的,或者找第三方的如果是OPEN XML 格式的 WORD 文档, 看看给有类库,没有大不了自己看格式介绍,不过估计东西很多调用打开word就简单了,各种打开方法,shell等等,cmd命令,都会自动调用默认程序打开的不行就自己搜索注册表,搜索word.exe或者wps.exe,忘记具体程序名了,自己传递参数调用打开
用vc操作word,怎样才能知道打开word已经完成
三种方法:一是直接读取.doc文档,可以将所有的文本读入到字符串中在做相关处理:C# code?using System.IO;string temp = System.IO.File.OpenText(@“D:\word.doc”).ReadToEnd();//读取doc文档二是通过调用.NET对于Office的COM组件来做:C# code?using Microsoft.Office.Interop.Word;Microsoft.Office.Interop.Word.Application app = new Microsoft.Office.Interop.Word.Application();//打开word程序Microsoft.Office.Interop.Word.Document doc = null;//实例化一个新的word文档object unknow = Type.Missing;app.Visible = true;doc = app.Documents.Open(ref fileName,ref unknow,ref unknow,ref unknow,ref unknow,ref unknow,ref unknow,ref unknow,ref unknow,ref unknow,ref unknow,ref unknow,ref unknow,ref unknow,ref unknow,ref unknow);string temp = doc.Content.Text.Trim();//将全篇内容存入字符串中,也可以调用别的方法,具体可以查询MSDN...三是将Word转为XML,可以根据要求提取内容,包括标题,目录等等~~C# code?using System.XML;XmlDocument doc = new XmlDocument();doc.Load(filePath); //载入XML文档XmlElement root = doc.DocumentElement; //定义载入XML的根节点foreach(XmlNode xn1 in root.ChildNodes) //对于根节点以外的子节点做循环,以下同理{//对元素处理~~~}...
vc搜索word和pdf文档,可否加入算法
#include "stdafx.h"#pragma warning(disable:4259)#import "C:\\Program Files\\Common Files\\Microsoft Shared\\Office11\\MSO.DLL" rename("IAccessible", "msoIAccessible")using namespace Office;#import "C:\\Program Files\\Common Files\\Microsoft Shared\\VBA\\VBA6\\VBE6EXT.OLB"//using namespace VBIDE; #import "d:\\Program Files\\Microsoft Office\\OFFICE11\\MSWORD.OLB" rename("ExitWindows","WordExitWindows")using namespace Word;#include #include using namespace std;int _tmain(int argc, _TCHAR* argv[]){CoInitialize(0);{_ApplicationPtr m_WordPtr;DocumentsPtr m_DocsPtr;_DocumentPtr m_DocPtr;HRESULT hr;try{//CLSID sid;//CLSIDFromProgID(L"word.application",&sid);hr=m_WordPtr.CreateInstance(__uuidof(Application)); m_WordPtr->put_Visible(VARIANT_TRUE);m_DocPtr=m_WordPtr->Documents->Add();LPSTR a = "c:\\22.doc";CComBSTR b = a;BSTR c = b.m_str;VARIANT va;va.vt = VT_BSTR;va.bstrVal = c;m_WordPtr->Documents->Open(&va);SelectionPtr sel=m_WordPtr->GetSelection();sel->TypeText(_bstr_t("sadsaS12as"));sel->MoveEnd();InlineShapePtr sh=sel->GetInlineShapes()->AddPicture(_bstr_t("c:\\1.jpg"));sel->SetRange(1,2);//sel->TypeText(_bstr_t("!!!!!!!"));_bstr_t text=sel->GetText();char *s=_com_util::ConvertBSTRToString(text);coutTablesPtr tables = sel->GetTables();TablePtr table = tables->Add(sel->GetRange(), 2, 5);BordersPtr bords = table->GetBorders();bords->PutOutsideLineStyle(wdLineStyleSingle);bords->PutOutsideLineWidth(wdLineWidth150pt);bords->PutInsideLineStyle(wdLineStyleSingle);for (int i = 1; i{for (int j = 1; j{table->Cell(i,j)->GetRange()->PutText("20");}}
转载请注明出处51数据库 » vc 锁定word文档
阿弥陀佛动感光波