问题如标题.........希望大侠们帮我解决下,可能的话给点简短代码提示下......无限感激~~~
解决方案 »
- C++文件框调用问题
- 快毕业了,想做个程序员,大家给点建议~
- 如果计算一段文字需要多少大小的矩形正好能够容其输出
- 请问一下,用VC6.0 如何设置编译参数,使编译所有的函数,包括没有使用的。
- 使用AfxBeginThread编译错误:error C2440: 'type cast' : cannot convert from '' to 'unsigned int (__cdecl *)(void *)'
- 如何删除ini文件中某一项?? 在线等
- **-------简单问题 不知道有人回答么: 线程结束后, 线程句柄==NULL 了吗?--------------***
- 重奖500分,绝无虚言: 在客户区指定区域显示powerpoint的某一页面?
- 在用网络编程时(csocket)异步与同步是什么意思?望指教!
- GetUserName怎么用啊?
- VC6.0+MapX,如何实现点击某轨迹点时跳出一个对应的属性框?
- 用获取多接口CoCreateInstanceEx问题
你可以参考一下
http://www.vckbase.com/document/viewdoc/?id=1174
而且用VC2005导入的时候他的文件时有些变化了!
里面的例子我都看过了,稍微修改下,套进去还是用不了,是不是没捕抓到webbroswer打开的word文件啊,所以无法操作啊?
_Application app;
app.CreateDispatch(_T("Word.Application"));
// app.SetVisible(TRUE); Documents docs=app.GetDocuments();
CComVariant Template(_T(""));
CComVariant NewTemplate(false),DocumentType(0),Visible;
docs.Add(&Template,&NewTemplate,&DocumentType,&Visible);
_Document doc=app.GetActiveDocument();
CComVariant FileName(_T("c:\\doc.doc")); //文件名
CComVariant FileFormat(0);
CComVariant LockComments(false),Password(_T(""));
CComVariant AddToRecentFiles(true),WritePassword(_T(""));
CComVariant ReadOnlyRecommended(false),EmbedTrueTypeFonts(false);
CComVariant SaveNativePictureFormat(false),SaveFormsData(false);
CComVariant SaveAsAOCELetter(false);
doc.SaveAs(&FileName,&FileFormat,&LockComments,&Password,
&AddToRecentFiles,&WritePassword,&ReadOnlyRecommended,
&EmbedTrueTypeFonts,&SaveNativePictureFormat,&SaveFormsData,
&SaveAsAOCELetter,NULL,NULL,NULL,NULL,NULL);
doc.ReleaseDispatch();
docs.ReleaseDispatch();
CComVariant SaveChanges(false),OriginalFormat,RouteDocument;
app.Quit(&SaveChanges,&OriginalFormat,&RouteDocument);
app.ReleaseDispatch();
app.Quit(&SaveChanges,&OriginalFormat,&RouteDocument);
app.ReleaseDispatch();报错:向占位程序传送了空的索引指针
_Application app;
app.CreateDispatch(_T("Word.Application"));
// app.SetVisible(TRUE);Documents docs=app.GetDocuments();
CComVariant Template(_T(""));
CComVariant NewTemplate(false),DocumentType(0),Visible;
docs.Add(&Template,&NewTemplate,&DocumentType,&Visible);_Document doc=app.GetActiveDocument();
CComVariant FileName(_T("c:\\doc.doc")); //文件名
CComVariant FileFormat(0);
CComVariant LockComments(false),Password(_T(""));
CComVariant AddToRecentFiles(true),WritePassword(_T(""));
CComVariant ReadOnlyRecommended(false),EmbedTrueTypeFonts(false);
CComVariant SaveNativePictureFormat(false),SaveFormsData(false);
CComVariant SaveAsAOCELetter(false);doc.SaveAs(&FileName,&FileFormat,&LockComments,&Password,
&AddToRecentFiles,&WritePassword,&ReadOnlyRecommended,
&EmbedTrueTypeFonts,&SaveNativePictureFormat,&SaveFormsData,
&SaveAsAOCELetter,NULL,NULL,NULL,NULL,NULL);
doc.ReleaseDispatch();
docs.ReleaseDispatch();CComVariant SaveChanges(false),OriginalFormat,RouteDocument;
app.Quit(&SaveChanges,&OriginalFormat,&RouteDocument);
app.ReleaseDispatch();app.Quit(&SaveChanges,&OriginalFormat,&RouteDocument);
app.ReleaseDispatch();报错:向占位程序传送了空的索引指针
#include "CDocuments.h"
#include "CSentences.h"
#include "CDocument0.h"
#include <atlbase.h>
void CStep1Dlg::OnBnClickedOk()
{
CApplication app;
app.CreateDispatch(_T("Word.Application"));
app.put_Visible(TRUE); CDocuments docs = app.get_Documents();
CComVariant Template(_T(""));
CComVariant NewTemplate(false),DocumentType(0),Visible;
docs.Add(&Template,&NewTemplate,&DocumentType,&Visible); CSentences sel = app.get_Selection();
sel.TypeText(_T("HELLO\r\n大家好呀")); AfxMessageBox(_T("好了,我要保存到c:\\hello.doc中了"));
CDocument0 doc = app.get_ActiveDocument(); //得到ActiveDocument
CComVariant FileName(_T("c:\\Hello.doc")); //文件名
CComVariant FileFormat(0); //重点,看下面的说明
CComVariant LockComments(false),Password(_T(""));
CComVariant AddToRecentFiles(true),WritePassword(_T(""));
CComVariant ReadOnlyRecommended(false),EmbedTrueTypeFonts(false);
CComVariant SaveNativePictureFormat(false),SaveFormsData(false);
CComVariant SaveAsAOCELetter(false);
doc.SaveAs2000(&FileName,&FileFormat,&LockComments,&Password,
&AddToRecentFiles,&WritePassword,&ReadOnlyRecommended,
&EmbedTrueTypeFonts,&SaveNativePictureFormat,&SaveFormsData,&SaveAsAOCELetter);
sel.ReleaseDispatch();
doc.ReleaseDispatch();
docs.ReleaseDispatch(); CComVariant SaveChanges(false),OriginalFormat,RouteDocument;
app.Quit(&SaveChanges,&OriginalFormat,&RouteDocument);
app.ReleaseDispatch();
AfxMessageBox(_T("请检查c:\\hello.doc是否正常产生了。下面该学习Setp5了"));
}