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 Forum for Programming
 Forum for Origin C
 Problems with COM / 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 [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
Campo Posted - 04/24/2006 : 3:51:29 PM
Origin Version: 7.5 pro
Operating System: WinXP

sorry, i am a newb in programming origin c and c++ and I have following problem: I want to copy a graph into ms word. But i dont want to create a "bmp", like in the COM-Example.
I found here:
http://www.originlab.com/forum/topic.asp?TOPIC_ID=3775
a interesting suggestion with a code how to export graphs to excel. My code is similar but broken and i cant find my failure.

can somebody help me?

quote:

void pasting_to_Word()

{

// Word öffnen
Object oWord, oWordDoc;

GraphPage gp;

oWord = CreateObject("Word.Application");

oWord.Visible = true;

// neues Word-Dokument erstellen
string strFldPath = GetAppPath(true) + "Samples\\COM Client\\";

oWordDoc = oWord.Documents.Add(Template := strFldPath + "ReportTemplate.dot");

// Graph auswählen
string strName = gp.GetName();

out_str(strName);

BOOL bShown = gp.Show;
if (!bShown)
gp.Show = TRUE;
string strLtcmd = "clipboard " + strName;
gp.LT_execute(strLtcmd);
if (!bShown)
gp.Show = FALSE;

// Einfügen des Graphs
oWordDoc. Add.Content.PasteSpecial();

}

3   L A T E S T    R E P L I E S    (Newest First)
easwar Posted - 04/25/2006 : 10:31:47 AM
quote:

Is ist also possible to paste the OLE to a spezial place on the table and not only to the first cell?
for examble: paste the graph to table 2, cell 2 and row 2



Hi Campo,

That particular Word template was saved with the cursor docked in table cell (1,1). You should be able to change/move the cursor to a different cell first and then do the pasting. You will need to look up Word VB command to change selection/move cursor.

Easwar
OriginLab

Campo Posted - 04/25/2006 : 04:35:39 AM
great,this helped a lot!!!! Thank you easwar

I hope the size of the table cell is no problem. but i have an other question. Is ist also possible to paste the OLE to a spezial place on the table and not only to the first cell?
for examble: paste the graph to table 2, cell 2 and row 2

easwar Posted - 04/24/2006 : 4:39:41 PM
Hi Campo,

A couple of options come to mind...

1> You can look at the ReportCreation.c file in \Sanmples\COM Client subfolder and edit that and change BMP to EMF, including in the Image.Export.PageDPI() method and thus use the export method to export EMF file instead of BMP and use the exported file and insert that into word similar to that example

2> Change your code as follows: I could paste the image from clipboard into the first cell of table, but looks like some follow up command is needed to resize the table cell - or perhaps that is another setting in paste - need to look up VB code details...

Note that paste can be OLE paste or metafile paste, depending on specification of paste type argument in last line.
Hope this helps.

Easwar
OriginLab


// Need to get Word VB constants for paste type - can look in visual basic editor under Word
#define wdPasteOLEObject 0
#define wdPasteMetafilePicture 3

void pasting_to_Word()

{
// Word öffnen
Object oWord, oWordDoc;

// Need to point to active page and check validity?
GraphPage gp = Project.Pages();
if( !gp ) return;

oWord = CreateObject("Word.Application");

oWord.Visible = true;

// neues Word-Dokument erstellen
string strFldPath = GetAppPath(true) + "Samples\\COM Client\\";

oWordDoc = oWord.Documents.Add(Template := strFldPath + "ReportTemplate.dot");

// Graph auswählen
string strName = gp.GetName();

out_str(strName);

BOOL bShown = gp.Show;
if (!bShown)
gp.Show = TRUE;
string strLtcmd = "clipboard " + strName;
gp.LT_execute(strLtcmd);
if (!bShown)
gp.Show = FALSE;

// Einfügen des Graphs
// Selection referes to where the cursor is located,
// and that is Word Application property, not Word Doc property
oWord.Selection.Range.PasteSpecial(DataType:=wdPasteOLEObject );
// Need to resize table cell....need to look that up...
}




Edited by - easwar on 04/24/2006 4:40:54 PM

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