首页 新闻 搜索 专区 学院

TWordApplication/TWordDocument bcb office2k 添加图片

0
[待解决问题]

String strPic("D:\\捕获.PNG");
OleVariant WordFile(strPic+_T(".doc"));
WordApp->Connect();

OleVariant NewTemplate(false);
OleVariant Template;
OleVariant DocumentType(0);
OleVariant Visible(false);
//调用Add函数
WordApp->Documents->Add(Template,NewTemplate,DocumentType,Visible);
//连接到新建的文档
WordDocument->ConnectTo(WordApp->Documents->Item(Variant(1)));

BSTR FileName=strPic.w_str();
TImage* imagePdf = new TImage(this);
imagePdf->Picture->LoadFromFile(strPic);
WordApp->Selection->PageSetup->PageHeight =imagePdf->Picture->Height;
WordApp->Selection->PageSetup->PageWidth =imagePdf->Picture->Width;
imagePdf->Picture->Graphic = NULL;
delete imagePdf;
imagePdf=NULL;
OleVariant LinkToFile(false), SaveWithDocument(false);
WordDocument->InlineShapes->AddPicture(FileName);

OleVariant pdfFile(strPic+_T(".pic.pdf"));
OleVariant format(17);
WordDocument->SaveAs(pdfFile, format);
OleVariant changeClose(false);
WordDocument->Close(changeClose);
WordApp->Disconnect();

 

 

报错:

this->AddPicture(FileName, LinkToFile, SaveWithDocument, Range, (Word_2k::InlineShape**)&prop))
Error: 800A1420 (-2146823136) @ c:\\program files (x86)\\embarcadero\\rad studio\\7.0\\include\\vcl\\Word_2K.h/32262\nPress [Y]es to terminate,[N]o to continue and [C]ancel to Debug

胸腹肌食神程序猿的主页 胸腹肌食神程序猿 | 菜鸟二级 | 园豆:203
提问于:2018-01-30 17:38
< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册