| Author |
Topic  |
|
|
hajo
Germany
Posts |
Posted - 03/03/2005 : 11:39:10 AM
|
Origin Version (Select Help-->About Origin): 7.5ProSR5 Operating System:WinXP
Hello, All
I want to export some GraphPages as OLE objects to e.g. Powerpoint (like CNTR+J) using OriginC
Is there any code available or can anybody post some, so I can get some impression how to do that.
(I want to avoid to export to bitmap first and then to imort the bitmap to the target application ...)
Thanks for your help Hajo
-- Dipl.-Ing. Hans-Joerg Koch SiemensVDO Automotive, Regensburg, Germany
|
|
|
easwar
USA
1965 Posts |
Posted - 03/03/2005 : 12:06:12 PM
|
Hi Hajo,
1> If you are running Origin as the client and Power Point as server application (possible with COM Client programming if you have OriginPro), then you can use the LabTalk command clipboard winname to first copy the graph page to clipboard, and then issue the appropriate command to the server application to paste the data as either static picture or as OLE embedded object, which is equivalent to the options under the paste special menu - you will need to look up the PowerPoint command on how to do this.
2> If you are running Origin as server and Power Point as client application, you can use the method: originObject.CopyPage() to get the page into clipboard and then follow up with necessary code to paste in the client application. For example, in Excel, once the graph has been copied to clipboard in Origin, it can be OLE-pasted to a particular cell location using VB code such as:
Set rng = range("a23:a23") rng.PasteSpecial
Easwar OriginLab
Edited by - easwar on 03/03/2005 12:52:20 PM |
 |
|
|
hajo
Germany
Posts |
Posted - 03/04/2005 : 02:57:23 AM
|
Hello, Easwar
thanks for the hint. I'll look into that and report ...
So far Hajo
-- Dipl.-Ing. Hans-Joerg Koch SiemensVDO Automotive, Regensburg, Germany
|
 |
|
|
hajo
Germany
Posts |
Posted - 03/04/2005 : 05:08:43 AM
|
hello, all
here's the code I use as base for my functionality ... + some comments & questions ...
void exportOLEApp(int appType = TARGET_APP_MSPPT) { Object ppApp, ppPres, ppSlide, ppShape; string strGpName, strLtcmd; ppApp = CreateObject("PowerPoint.Application"); ppApp.Visible = true; // zunaechst verdeckt oeffnen; erst nach dem vollstaendigen // Einfuegen der Bilder sichtbar machen ppPres = ppApp.Presentations.Add(true); //ppPres = ppApp.Presentations.Open(template, true); if(OpenClipboard(NULL)) { EmptyClipboard(); CloseClipboard(); } foreach(GraphPage gp in Project.GraphPages) { strGpName = gp.GetName(); set_active_layer(gp.Layers()); if(page_active_layer_index(gp)!=-1) { strLtcmd = "clipboard "+strGpName; gp.LT_execute(strLtcmd);
ppSlide = ppPres.Slides.Add((ppPres.Slides.Count + 1),ppLayoutBlank); ppShape = ppSlide.Shapes.PasteSpecial(); } else printf("Page: %s was not active!!\n", strGpName); } }
Copying from Origin to an other application using the clipboard is more tricky I expected!
1) in the foreach loop I have to activate each GraphPage seperately by the call "set_active_layer(gp.Layers())". I had expected that by looping through the Collection for getting the GraphPage is enough ... 2) The call gp.LT_execute("LTCODE") doesn't activate, as documented in the help, the calling page (gp) and restores the former activated page ....
3) How can I do the same using OriginC only?
Please comment ... So far Hajo
-- Dipl.-Ing. Hans-Joerg Koch SiemensVDO Automotive, Regensburg, Germany
Edited by - hajo on 03/04/2005 05:09:56 AM
Edited by - hajo on 03/04/2005 05:11:07 AM |
 |
|
|
ML
USA
63 Posts |
Posted - 03/04/2005 : 11:42:56 AM
|
Hi Hajo,
Here is how it can be done by only executing Copy via a LT call:
void test_copying_multiple_graps_and_pasting_to_Excel() { Object oExcel, oworkbooks, oworkbook, oworksheet, oRange; GraphPage gp; oExcel = CreateObject("Excel.Application"); oExcel.Visible = true; oworkbooks = oExcel.Workbooks; oworkbook = oworkbooks.Add(); oworksheet = oworkbook.ActiveSheet; int ii = 0; foreach(gp in Project.GraphPages) { 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; string strRange; char chCol = 'A' + ii; strRange.Format("$%c$%d", chCol, ii + 1); oRange = oworksheet.Range(strRange); oRange.PasteSpecial(); ii += 3; } }
In the function I paste into Excel, as I could not get your PowerPoint code to compile.
Note the call to show a window if hidden in order to successfully copy.
ML
|
 |
|
|
hajo
Germany
Posts |
Posted - 03/04/2005 : 3:12:49 PM
|
Thanks ML for the code...
It looks quite similar to my PPT code (The compile error is bacause of the page constant to import - "ppLayoutBlank" - don't know the numeric value, might be 0 - am I right?)
Is there a possibility to do something similar in OriginC like the LabTalk call "clipboard pageName"?
I think that would be a feature for further versions to have a real OriginC function to copy the OLE object to clipboard directly without using the "fallback" to LabTalk ...
So far Hajo
-- Dipl.-Ing. Hans-Joerg Koch SiemensVDO Automotive, Regensburg, Germany
|
 |
|
|
ML
USA
63 Posts |
Posted - 03/04/2005 : 5:12:32 PM
|
We will try to add a friendly "CopyPage()" method to GraphPage class in the future.
Thanks.
ML
|
 |
|
|
hajo
Germany
Posts |
Posted - 03/05/2005 : 08:17:58 AM
|
Hello, ML
don't forget the LayoutPage ....
Thanks Hajo
-- Dipl.-Ing. Hans-Joerg Koch SiemensVDO Automotive, Regensburg, Germany
|
 |
|
|
ML
USA
63 Posts |
Posted - 03/06/2005 : 6:13:45 PM
|
It's been tracked as 7466.
ML
|
 |
|
|
hajo
Germany
Posts |
Posted - 03/10/2005 : 2:49:00 PM
|
Hello, All
does anybody now, when MS introduced the PasteSpecial() function to Powerpoint.
There are problems for MS PPT 2000 I know of, PPT-2003 is working fine ... But what about the versions between ....
Thanks Hajo
-- Dipl.-Ing. Hans-Joerg Koch SiemensVDO Automotive, Regensburg, Germany
|
 |
|
| |
Topic  |
|
|
|