首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ Builder >

如何才能把image里面画的图片传送到word里面

2013-01-01 
怎么才能把image里面画的图片传送到word里面怎么才能把image里面画的图片传送到word里面,在image里面我的

怎么才能把image里面画的图片传送到word里面
怎么才能把image里面画的图片传送到word里面,在image里面我的图型已经画好了,是个二维坐标系,现在就是希望可以传送到word里面,弄了个半天还是不会弄,网上关于这个的也没有。
[解决办法]
http://bbs.csdn.net/topics/310237142
强力搬运工
[解决办法]
挖卡卡,省的我再重写了。
[解决办法]
我把图片插入到word中的表格中,
代码供你参考


void __fastcall TfmSearch::btExportWordClick(TObject *Sender)
{
try
{
if(edTollID->Text!=""&&edTollDate->Text!="")
{
AnsiString asDir;
AnsiString  asSFile = fmMain->g_asWorkPath + "\\doc\\lt.doc";
AnsiString  asDFile = "d:\" + edTollID->Text + ".doc";
CopyFile(asSFile.c_str(),asDFile.c_str(),false);

//保存电子文档
Variant vWordApp;
Variant vDoc, vTable,vCell;
DWORD ErrCode;
HWND hPrevApp = FindWindow(NULL,"Microsoft Word");

if(!hPrevApp)
{ //if word not started
try
{
vWordApp=CreateOleObject("Word.Application");
}
catch(...)
{
//MessageBox(Handle, "启动Word出错!", Application->Title.c_str(), MB_OK 
[解决办法]
 MB_ICONERROR);
return;
}
}
else
vWordApp=GetActiveOleObject("Word.Application");

vWordApp.OlePropertySet("Visible", true);
WideString strDocName = asDFile;
vDoc = vWordApp.OlePropertyGet("Documents").OleFunction("Open", strDocName);
vTable=vWordApp.OlePropertyGet("ActiveDocument").OleFunction("Range").OlePropertyGet("Tables").OleFunction("Item", 1);

vCell=vTable.OleFunction("Cell",1,2);
AnsiString Content=edTollID->Text;//FormatDateTime("yyyymmdd",fmMain->dtDOCDate);
vCell.OlePropertySet("Range",Content.c_str());

vCell=vTable.OleFunction("Cell",1,4);
Content=edTollDate->Text;//fmMain->asDOCVehType;
vCell.OlePropertySet("Range",Content.c_str());

vCell=vTable.OleFunction("Cell",1,6);
Content=edLicPlate->Text;//fmMain->asDOCLic;
vCell.OlePropertySet("Range",Content.c_str());

vCell=vTable.OleFunction("Cell",1,8);
Content=edVehType->Text;//fmMain->asDOCOpTicket;
vCell.OlePropertySet("Range",Content.c_str());



vCell=vTable.OleFunction("Cell",2,2);
Content=edEPLAZAName->Text;
vCell.OlePropertySet("Range",Content.c_str());

vCell=vTable.OleFunction("Cell",2,4);
Content=edOperatorName->Text;
vCell.OlePropertySet("Range",Content.c_str());

vCell=vTable.OleFunction("Cell",2,6);
Content=edTollPay->Text;
vCell.OlePropertySet("Range",Content.c_str());

vCell=vTable.OleFunction("Cell",2,8);
Content=edCarWeight->Text;
vCell.OlePropertySet("Range",Content.c_str());

vCell=vTable.OleFunction("Cell",3,2);
Content=edOverloadPer->Text;
vCell.OlePropertySet("Range",Content.c_str());

vCell=vTable.OleFunction("Cell",3,4);
Content=edGoodsName->Text;//fmMain->asDOCGoodsName;
if(edMixGoodsName->Text.Trim()!="")
Content+="+" +edMixGoodsName->Text.Trim();
vCell.OlePropertySet("Range",Content.c_str());

vCell=vTable.OleFunction("Cell",3,6);
Content=edDensity->Text;
vCell.OlePropertySet("Range",Content.c_str());

vCell=vTable.OleFunction("Cell",3,8);
Content=edCheckName->Text;


vCell.OlePropertySet("Range",Content.c_str());

AnsiString strPicFile;

asDir="d:";
String picFileName;
try
{
picFileName= asDir+"\\前部照片.jpeg";
imgFront->Picture->SaveToFile(picFileName);
picFileName= asDir+"\\顶部照片.jpeg";
imgTop->Picture->SaveToFile(picFileName);
picFileName= asDir+"\\全景照片.jpeg";
imgTotal->Picture->SaveToFile(picFileName);
picFileName= asDir+"\\左后侧照片.jpeg";
imgLeft->Picture->SaveToFile(picFileName);
picFileName= asDir+"\\右后侧照片.jpeg";
imgRight->Picture->SaveToFile(picFileName);
picFileName= asDir+"\\货物照片.jpeg";
imgCheck->Picture->SaveToFile(picFileName);
ExportDVfile();//导出录像
}
catch(...)
{
//
}
try
{
strPicFile = asDir + "\\前部照片.jpeg";

    Variant vShape;
vTable=vWordApp.OlePropertyGet("ActiveDocument").OleFunction("Range").OlePropertyGet("Tables").OleFunction("Item", 2);
    vCell=vTable.OleFunction("Cell",1,1);
    vCell.OleFunction("select");
    vShape =vWordApp.OlePropertyGet("Selection")
                           .OlePropertyGet("InlineShapes")
                           .OleFunction("AddPicture", strPicFile.c_str(),false,true);

strPicFile = asDir + "\\顶部照片.jpeg";
vTable=vWordApp.OlePropertyGet("ActiveDocument").OleFunction("Range").OlePropertyGet("Tables").OleFunction("Item", 2);
    vCell=vTable.OleFunction("Cell",1,2);
    vCell.OleFunction("select");
    vShape =vWordApp.OlePropertyGet("Selection")
                           .OlePropertyGet("InlineShapes")
                           .OleFunction("AddPicture", strPicFile.c_str(),false,true);

strPicFile = asDir + "\\全景照片.jpeg";
vTable=vWordApp.OlePropertyGet("ActiveDocument").OleFunction("Range").OlePropertyGet("Tables").OleFunction("Item", 2);
    vCell=vTable.OleFunction("Cell",1,3);
    vCell.OleFunction("select");
    vShape =vWordApp.OlePropertyGet("Selection")
                           .OlePropertyGet("InlineShapes")
                           .OleFunction("AddPicture", strPicFile.c_str(),false,true);

strPicFile = asDir + "\\左后侧照片.jpeg";
vTable=vWordApp.OlePropertyGet("ActiveDocument").OleFunction("Range").OlePropertyGet("Tables").OleFunction("Item", 2);
    vCell=vTable.OleFunction("Cell",3,1);
    vCell.OleFunction("select");
    vShape =vWordApp.OlePropertyGet("Selection")
                           .OlePropertyGet("InlineShapes")


                           .OleFunction("AddPicture", strPicFile.c_str(),false,true);

strPicFile = asDir + "\\右后侧照片.jpeg";
vTable=vWordApp.OlePropertyGet("ActiveDocument").OleFunction("Range").OlePropertyGet("Tables").OleFunction("Item", 2);
    vCell=vTable.OleFunction("Cell",3,2);
    vCell.OleFunction("select");
    vShape =vWordApp.OlePropertyGet("Selection")
                           .OlePropertyGet("InlineShapes")
                           .OleFunction("AddPicture", strPicFile.c_str(),false,true);

    strPicFile = asDir + "\\货物照片.jpeg";
vTable=vWordApp.OlePropertyGet("ActiveDocument").OleFunction("Range").OlePropertyGet("Tables").OleFunction("Item", 2);
    vCell=vTable.OleFunction("Cell",3,3);
    vCell.OleFunction("select");
    vShape =vWordApp.OlePropertyGet("Selection")
                           .OlePropertyGet("InlineShapes")
                           .OleFunction("AddPicture", strPicFile.c_str(),false,true);

  vWordApp.OlePropertyGet("Documents").OleFunction("Save");
//  vWordApp.OlePropertyGet("Documents").OleFunction("Close");
//  vWordApp.OleFunction("Quit");
  }
  catch(...)
  {
  //
  }
//  fmMain->g_bCancle = true;
/*
  if(!fmMain->g_bDOCPhotoErr)
  {
    //删除照片
    AnsiString usPhotoName;
    usPhotoName = asDir + "\\车辆全貌.jpeg";
    if(FileExists(usPhotoName)) DeleteFile(usPhotoName);
    usPhotoName = asDir + "\\前部照片.jpeg";
    if(FileExists(usPhotoName)) DeleteFile(usPhotoName);
    usPhotoName = asDir + "\\上方货物.jpeg";
    if(FileExists(usPhotoName)) DeleteFile(usPhotoName);
    usPhotoName = asDir + "\\左侧货物.jpeg";
    if(FileExists(usPhotoName)) DeleteFile(usPhotoName);
    usPhotoName = asDir + "\\右侧货物.jpeg";
    if(FileExists(usPhotoName)) DeleteFile(usPhotoName);
    usPhotoName = asDir + "\\后方货物.jpeg";
    if(FileExists(usPhotoName)) DeleteFile(usPhotoName);
  }*/
}
else
{
           ShowMessage("请选择单个车辆!");
        }
}
catch(...)
{
ShowMessage("导出数据失败!");
    }
}

热点排行