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
 How to clip one more graph to the 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

70WorkRoom

China
Posts

Posted - 07/16/2007 :  09:53:59 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Version (Select Help-->About Origin): Origin pro v7.5
Operating System:windows 2000

When I write the code as follow,i can only clip one graph to the word,and i must make a table first to Insert some strings to the word.
How can i clip more graph to the one word file,and insert strings to the word without table template?

 
void pasting_to_Word(string strGraph,string strContent,string strFileName)
{
Object oWord, oWordDoc;
// Need to point to active page and check validity?

GraphPage gp = Project.Pages(strGraph);
if( !gp ) return;

oWord = CreateObject("Word.Application");
oWord.Visible = false;
// neues Word-Dokument erstellen
string strFldPath = GetFilePath(__FILE__);
oWordDoc = oWord.Documents.Add(Template := strFldPath + "Template.doc");

oWordDoc.Tables(1).Cell(Row := 1, Column := 1).Range.InsertAfter(Text := strContent);

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;

// Selection referes to where the cursor is located,
// and that is Word Application property, not Word Doc property
oWord.Selection.Range.PasteSpecial(DataType:=wdPasteOLEObject );
oWordDoc.SaveAs(FileName := "C:\\" + strFileName + ".doc");
oWordDoc.Quit();
// Need to resize table cell....need to look that up...
}

joseph_king

China
Posts

Posted - 07/19/2007 :  03:40:18 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi 70WorkRoom,
Could you try using the following code? The following sample show how to clip 2 graphs to the one word file and solve your problem.


void pasting_to_Word(string strGraph1,string strGraph2, string strContent,string strFileName)
{

Object oWord, oWordDoc;

// Need to point to active page and check validity?


oWord = CreateObject("Word.Application");

oWord.Visible = false;

// neues Word-Dokument erstellen

string strFldPath = GetFilePath(__FILE__);

/************* you don't need to apply a template *******************/
//oWordDoc = oWord.Documents.Add(Template := strFldPath + "Template.doc");
//oWordDoc.Tables(1).Cell(Row := 1, Column := 1).Range.InsertAfter(Text := strContent);

oWordDoc = oWord.Documents.Add();
oWord.Selection.TypeText(strContent);
oWord.Selection.TypeParagraph();
/***************************** end *********************************/


GraphPage gp = Project.Pages(strGraph1);
if( !gp ) return;

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;

// Selection referes to where the cursor is located,
// and that is Word Application property, not Word Doc property
oWord.Selection.Paste();


/******************Copy the second graph**********************/
gp = Project.Pages(strGraph2);
strName = gp.GetName();
out_str(strName);
bShown = gp.Show;

if (!bShown)
gp.Show = TRUE;

strLtcmd = "clipboard " + strName;
gp.LT_execute(strLtcmd);
oWord.Selection.Paste();
/************************* end *****************************/


oWordDoc.SaveAs(FileName := "C:\\" + strFileName + ".doc");
oWord.Quit();
// Need to resize table cell....need to look that up...
}


Joeseph King
OriginLab Technical Services

Edited by - joseph_king on 07/19/2007 03:51:39 AM
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