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
 All Forums
 Origin中文论坛
 Origin 中文论坛 (Chinese Origin Forum)
 origin向word表格内粘贴图片

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Anti-Spam Code:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkUpload FileInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
   

T O P I C    R E V I E W
lisa2021 Posted - 11/21/2022 : 02:08:04 AM
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);

请问是什么原因,应该如何解决?
还望解答,谢谢!
3   L A T E S T    R E P L I E S    (Newest First)
Castiel Posted - 11/27/2022 : 12:18:44 AM
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
------------------------------------------
lisa2021 Posted - 11/23/2022 : 10:38:30 PM
您好,代码如下:
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。
感谢您解答。
Castiel Posted - 11/21/2022 : 05:28:04 AM
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
------------------------------------------

The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000