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
 Origin Forum
 Problem with PutWorksheet from Delphi 7
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

uni460

Germany
2 Posts

Posted - 02/14/2007 :  08:47:45 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Version (Select Help-->About Origin): Origin Pro 7.5 SR6 v7.5885
Operating System: XP Prof. SR2

We want to use PutWorksheet from Dephi 7.
Execute, Createpage and GetWorksheet works fine.
However PutWorksheet always fails.
I tried PutWorksheet with the result-variantarray of GetWorksheet to
avoid errors in the format of the data-variantarray -> no success.
No Error message or exception is raised.
Also the demoapplication for C - SendNumericDataToWks.exe works.

Is there some known bug?
How is the required structure of the data-variantarray of PutWorksheet?
Is there an example for Delphi or an Borland-C compiler?

Thank you in advance.
Frank


Example Code:


uses comobj;
var Origin75pro : variant;

procedure TForm1.FormCreate(Sender: TObject);
begin
try
Origin75pro := CreateOleObject('Origin.ApplicationSI');
Origin75pro.Execute ('doc -mc 1');
Origin75pro.Createpage(2,'testdata','Origin'); // Works fine
except
ShowMessage('Could not start Origin75pro !');
Exit;
end;
end;

// put some data to worksheet 'testdata' before pressing the button
procedure TForm1.Button1Click(Sender: TObject);
var data:oleVariant;
wks_Name:widestring;
begin
wks_Name:= 'testdata';
data := VarArrayCreate([1,1,1,1], VarVariant);
try
data:=Origin75pro.GetWorksheet(wks_Name); // works fine
If not VarIsError(data) then begin
ShowMessage(VarToStr(data[1,1]));
data[1,1]:=55.0;
If not Origin75pro.PutWorksheet(wks_Name,data) then
// <-- PutWorksheet always returns false & no Data were transfered
ShowMessage('Put-Error');
end
else ShowMessage('Get-Error/NoData');
except
end;

end;

Deanna

China
Posts

Posted - 02/14/2007 :  8:35:36 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Frank.

Although I am not familiar with Delphi, your post reminds me of a similar case which is about a VB script. In the VB script, putworksheet() always returns false and the data cannot be transferred into Origin.

The reason why the script fails is that putworksheet() function requires the type of the variable, data, to be of VT_ARRAY, but the script pass a variable of VT_BYREF type to data.

I suggest checking the following line in your code:
        If not Origin75pro.PutWorksheet(wks_Name,data) then ...

Please make sure that data is passed by value instead of being passed by reference.

Deanna
OriginLab Technical Services


Edited by - Deanna on 02/14/2007 9:35:30 PM
Go to Top of Page

uni460

Germany
2 Posts

Posted - 02/16/2007 :  11:37:31 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Deanna,
Thank you for your prompt answer.
I have checked this.
In the programline before PutWorksheet
data has the VariantType $200C = VT_Array + VT_Variant.
The elements of data have the VariantType $0005= VT_Double = VT_R8.
VT_ByRef=$4000 is not set.
So unfortunately this is not the reason of the error.

Frank
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