The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
Username:
Password:
Save Password
Forgot your Password? | Admin Options

 All Forums
 Origin中文论坛
 Origin 中文论坛 (Chinese Origin Forum)
 origin向word表格内粘贴图片
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

lisa2021

China
6 Posts

Posted - 11/21/2022 :  02:08:04 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Ver. and Service Release (Select Help-->About Origin):
Operating System:
您好,我想将origin图片以嵌入式对象类型粘贴到word文档的表格内,但是只能粘贴到每行的第一列,无法粘贴到其他列。
主要代码如下:
GraphPage gp(gpname);
BOOL bOK=gp.LT_execute("type -qs 0;Clipboard %H;type -qs 1;");
if(bOK)
Table.Cell(Row:=RowNum,Column:=ColNum).Range.PasteSpecial(Placement:=wdline,DataType=wdPasteOLEObject,DisplayAsIcon:=0;Link:=0);

请问是什么原因,应该如何解决?
还望解答,谢谢!

Castiel

343 Posts

Posted - 11/21/2022 :  05:28:04 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
quote:
Originally posted by lisa2021

Origin Ver. and Service Release (Select Help-->About Origin):
Operating System:
您好,我想将origin图片以嵌入式对象类型粘贴到word文档的表格内,但是只能粘贴到每行的第一列,无法粘贴到其他列。
主要代码如下:
GraphPage gp(gpname);
BOOL bOK=gp.LT_execute("type -qs 0;Clipboard %H;type -qs 1;");
if(bOK)
Table.Cell(Row:=RowNum,Column:=ColNum).Range.PasteSpecial(Placement:=wdline,DataType=wdPasteOLEObject,DisplayAsIcon:=0;Link:=0);

请问是什么原因,应该如何解决?
还望解答,谢谢!



贴精简、完整且可复现问题的代码。


------------------------------------------
       Be The Change
             You Want To See
                   In The World
------------------------------------------
Go to Top of Page

lisa2021

China
6 Posts

Posted - 11/23/2022 :  10:38:30 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
您好,代码如下:
enum{
wdInline=0,
wdPasteOLEObject=0,
wdPasteMetafilePicture=3

};

bool copyFiguresToWordTable()
{
Worksheet wks;
wks.Create("Origin");
wks.AddCol();

for (int ii=0;ii<20;ii++)
{
wks.SetCell(ii,0,ii+1);
wks.SetCell(ii,1,ii*10);
}
/////////////
GraphPage gp;
gp.Create("Line");
GraphLayer gl=gp.Layers(0);
DataRange dr;
dr.Add(wks,0,"X");
dr.Add(wks,1,"Y");

int nplot=gl.AddPlot(dr,IDM_PLOT_LINESYMB);
if(nplot>=0)
{
gl.Rescale();
}
////////////
Object oWord,oWordDoc,oWordTable;
oWord=CreateObject("word.application");
if (!oWord)
return false;
oWord.Visible=1;
oWordDoc=oWord.Documents.Add();
try
{
oWordTable=oWord.Selection.Tables.Add(oWord.Selection.Range,2,2);
}
catch(int nError)
{
return false;
}
BOOL bOK=gp.LT_execute("type -qs 0;Clipboard %H;type -qs 1;");
if(bOK)
{
//////DataType:=wdPasteOLEObject时,均复制到每行第1列;DataType:=wdPasteMetafilePicture时,可正常复制
oWordTable.Cell(Row:=1,Column:=2).Range.PasteSpecial(Placement:=wdInline,DataType:=wdPasteOLEObject,DisplayAsIcon:=0,Link:=0);//问题:图片复制到第一行第一列
//oWordTable.Cell(Row:2,Column:=2).Range.PasteSpecial(Placement:=wdInline,DataType:=wdPasteOLEObject,DisplayAsIcon:=0,Link:=0);//问题:图片复制到第二行第一列
}
oWordDoc.SaveAs("D:\\test.doc");
oWord.Quit();
return true;
}

顺便说一下,我用的软件版本是:Origin2021,word2016。
感谢您解答。
Go to Top of Page

Castiel

343 Posts

Posted - 11/27/2022 :  12:18:44 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
quote:
Originally posted by lisa2021

您好,代码如下:
enum{
wdInline=0,
wdPasteOLEObject=0,
wdPasteMetafilePicture=3

};

bool copyFiguresToWordTable()
{
Worksheet wks;
wks.Create("Origin");
wks.AddCol();

for (int ii=0;ii<20;ii++)
{
wks.SetCell(ii,0,ii+1);
wks.SetCell(ii,1,ii*10);
}
/////////////
GraphPage gp;
gp.Create("Line");
GraphLayer gl=gp.Layers(0);
DataRange dr;
dr.Add(wks,0,"X");
dr.Add(wks,1,"Y");

int nplot=gl.AddPlot(dr,IDM_PLOT_LINESYMB);
if(nplot>=0)
{
gl.Rescale();
}
////////////
Object oWord,oWordDoc,oWordTable;
oWord=CreateObject("word.application");
if (!oWord)
return false;
oWord.Visible=1;
oWordDoc=oWord.Documents.Add();
try
{
oWordTable=oWord.Selection.Tables.Add(oWord.Selection.Range,2,2);
}
catch(int nError)
{
return false;
}
BOOL bOK=gp.LT_execute("type -qs 0;Clipboard %H;type -qs 1;");
if(bOK)
{
//////DataType:=wdPasteOLEObject时,均复制到每行第1列;DataType:=wdPasteMetafilePicture时,可正常复制
oWordTable.Cell(Row:=1,Column:=2).Range.PasteSpecial(Placement:=wdInline,DataType:=wdPasteOLEObject,DisplayAsIcon:=0,Link:=0);//问题:图片复制到第一行第一列
//oWordTable.Cell(Row:2,Column:=2).Range.PasteSpecial(Placement:=wdInline,DataType:=wdPasteOLEObject,DisplayAsIcon:=0,Link:=0);//问题:图片复制到第二行第一列
}
oWordDoc.SaveAs("D:\\test.doc");
oWord.Quit();
return true;
}

顺便说一下,我用的软件版本是:Origin2021,word2016。
感谢您解答。


oWordTable.Cell(1, 2).Select();
oWord.Selection.Range.InsertParagraph();
// oWord.Selection.Range.Delete();
oWord.Selection.PasteSpecial(...)



------------------------------------------
       Be The Change
             You Want To See
                   In The World
------------------------------------------
Go to Top of Page
  Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000