cancel
Showing results for 
Search instead for 
Did you mean: 

Open Office

SOLVED
Morgan
Frequent Contributor

Open Office

I am trying to open Open Office, click a specified tab in a specific document and copy all data on that tab.  In Excel, this seems to work great but I am having difficulty getting this to work in Open Office (or I'm just not thinking clearly today).  Any ideas?  



Working Excel script looks like...




  bk := AppPath +'Resources\Table.xls';


  


  Excel := Sys.OleObject('Excel.Application');


  


  Excel.Visible := True;                        


  


  While not Excel.Visible = true


        do delay (500, 'Waiting for Excel to open');

 


  Excel.Workbooks.Open (bk);   

1 ACCEPTED SOLUTION

Accepted Solutions
AlexKaras
Community Hero

RE: Open Office

Hi Morgan,



I did not work with Open Office, but hope that this might help: http://smartbear.com/forums/f75/t59967/oleobject-libre-office/
Regards,
  /Alex [Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
================================

View solution in original post

6 REPLIES 6
AlexKaras
Community Hero

RE: Open Office

Hi Morgan,



I did not work with Open Office, but hope that this might help: http://smartbear.com/forums/f75/t59967/oleobject-libre-office/
Regards,
  /Alex [Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
================================

View solution in original post

Morgan
Frequent Contributor

RE: Open Office

Thanks, Alexei - From that link I was able to find the following with an example which is proving to do what I want to in VBScript..

http://support.smartbear.com/viewarticle/54653/



I am having difficulty getting the example script converted to DelphiScript but I can muck with it more and see if I can get it.



Thank you!

Morgan
AlexKaras
Community Hero

RE: Open Office

Hi Morgan,



Actually, conversion from VBScript is easier than to VBScript because you should not bother whether or not use the Set keyword.

For the link that you mentioned I got this (untested, just converted while writing this reply):



procedure main();

  var ServiceManager : OleVariant;

  var Desktop : OleVariant;

  var Document : OleVariant;

  var Sheets : OleVariant;

  var Sheet : OleVariant;

  var SaveParam : OleVariant;

  var i, j : integer;

  var arr : OleVariant;

begin

  ServiceManager := Sys.OleObject('com.sun.star.ServiceManager');

  Desktop := ServiceManager.createInstance('com.sun.star.frame.Desktop');

  // arr = Array()

  arr := BuiltIn.CreateVariantArray(0, -1);

  Document := Desktop.LoadComponentFromURL('private:factory/scalc', '_blank', 0, arr);

  Sheets := Document.getSheets();

  Sheet := Sheets.getByIndex(0);

  Sheet.getCellByPosition(0, 0).SetFormula('My Table Title');

  for i := 0 to 9 do

  begin

    Sheet.getCellByPosition(i, 1).SetFormula(aqString.Format('Column %i', i+1));

    for j := 0 to 9 do

      Sheet.getCellByPosition(i, j+2).Value := i + j;

  end;

  SaveParam := ServiceManager.Bridge_GetStruct('com.sun.star.beans.PropertyValue');

  SaveParam.Name := 'FilterName';

  SaveParam.Value := 'MS Excel 97';

  arr := BuiltIn.CreateVariantArray(0, 0);

  arr[0] := SaveParam;

  Document.storeToURL('file:///c:/test.xls', arr);

end;





Hope, this will help...



P.S. I failed to make correct formatting, so please replace [ ] with a space and ['] with a single quote
Regards,
  /Alex [Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
================================
Morgan
Frequent Contributor

RE: Open Office

OH HAPPY DAY!!!  It works!!!!  Dumb question for you....  did you manually convert that or is there some function with TC that I am unaware of that will do it for me?  I am on an older version currently, if it matters.  Thank you SO much!
AlexKaras
Community Hero

RE: Open Office

Hi Morgan,



Great. Thank you for the update.

Conversion was done manually. Actually, especially if the author of the original code did not use language-specific functions and features but tried to use TestComplete's functions that do the same (I mentioned this in the "Namemapping nightmare" thread), the conversion is quite straightforward: delete all Set keywords; add semicolon at the end of every line; replace all = with := (considering conditions in the if/while/etc.); replace all double-quotes with the single ones and double single quotes inside strings; enclose procedure/function bodies within the begin/end block; etc.

There is no function in TestComplete that does the conversion, but after converting code to and from several times one usually has no problems with manual conversion.
Regards,
  /Alex [Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
================================
Morgan
Frequent Contributor

RE: Open Office

Thanks, Alexei - you've been very helpful!  Have a good day!
New Here?
Join us and watch the welcome video:
Announcements
Top Kudoed Authors