W
wangxq
Unregistered / Unconfirmed
GUEST, unregistred user!
我用 import type library 导入 word 类型库,然后打开一word 文档,在当前光标处插入一行文字,使用InsertBefore 函数,参数是wchar_t *text,程序如下:
#include "Word_TLB.h"
void __fastcall TForm1::Button1Click(TObject *Sender)
{
//虚拟表方式
TCOM_Application WordApp = CoApplication_::Create();
Variant FileName=TVariant ("c://Word.doc");
WordApp.Documents_->Open (FileName,EmptyParam,EmptyParam,EmptyParam,EmptyParam,EmptyParam,EmptyParam,EmptyParam,EmptyParam,EmptyParam);
WordApp.Visible =true;
AnsiString t="中国人民银行";
wchar_t *text=new wchar_t[t.WideCharBufSize()];
t.WideChar (text, t.WideCharBufSize()) ;
WordApp.Selection_->InsertBefore (text);
delete text;
}
运行后,已插入文本,但后面却跟着"□□□□□"字符,请问这是何原因?如何解决?
#include "Word_TLB.h"
void __fastcall TForm1::Button1Click(TObject *Sender)
{
//虚拟表方式
TCOM_Application WordApp = CoApplication_::Create();
Variant FileName=TVariant ("c://Word.doc");
WordApp.Documents_->Open (FileName,EmptyParam,EmptyParam,EmptyParam,EmptyParam,EmptyParam,EmptyParam,EmptyParam,EmptyParam,EmptyParam);
WordApp.Visible =true;
AnsiString t="中国人民银行";
wchar_t *text=new wchar_t[t.WideCharBufSize()];
t.WideChar (text, t.WideCharBufSize()) ;
WordApp.Selection_->InsertBefore (text);
delete text;
}
运行后,已插入文本,但后面却跟着"□□□□□"字符,请问这是何原因?如何解决?