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

Campo

Germany
Posts

Posted - 04/24/2006 :  3:51:29 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
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();

}

easwar

USA
1965 Posts

Posted - 04/24/2006 :  4:39:41 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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
Go to Top of Page

Campo

Germany
Posts

Posted - 04/25/2006 :  04:35:39 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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

Go to Top of Page

easwar

USA
1965 Posts

Posted - 04/25/2006 :  10:31:47 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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

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