Recent

Author Topic: office automation??  (Read 36036 times)

thales

  • New Member
  • *
  • Posts: 21
office automation??
« on: August 10, 2009, 07:25:54 pm »
hi folks.
i'm realatively new to lazarus... currently trying to migrate from delphi, and very important thing that i missed here, is the possibility for automating office procedures...
i found some topics here in the forum talking about it, but nothing much helpful, so, i kinda have some doubts about what i previously read here...

someone said that automating ms office is not possible because lazarus is supposed to work as multi-platform, and since ms office is a windows thing, doesnt fit.
...anyway, we have open office... does anyone know any way to automate that? like, the same way we'd do it in delphi using office's vba interface's commands, it was called 'ole automation', manipulating a variant object?

i understand that from delphi 5 on, we have those components that make binding a little bit easier... but since i used delphi 3, (and back then, there were no such components...), i'd do it via code...
(i intend to do it in lazarus via code...) which teorically should be pretty much the same...  :'( unfortunately, it's not...

could someone please show me some material about how to do that in lazarus? is there something i'd have to integrate to the ide?

any help?

THALES VAZ

theo

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1890
Re: office automation??
« Reply #1 on: August 10, 2009, 07:40:09 pm »

thales

  • New Member
  • *
  • Posts: 21
Re: office automation??
« Reply #2 on: August 10, 2009, 08:48:52 pm »
yeah, i've read that... more than once, actually...
but it doesnt explain much, right?

also, what is a uno bridge?
where do i get the automation servers this wiki mentions?
should i install any package?

theo

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1890
Re: office automation??
« Reply #3 on: August 10, 2009, 09:13:13 pm »
I'm not an expert.
There is a UNO bridge project here: http://sourceforge.net/projects/uno-pas-bridge/
but it doesn't look very active.

If you need to produce or read OpenOffice documents, you could also read or write them via
the Freepascal XML and Zip libraries. OO Documents are zipped XML files.

Phil

  • Hero Member
  • *****
  • Posts: 2750
Re: office automation??
« Reply #4 on: August 10, 2009, 09:31:34 pm »
yeah, i've read that... more than once, actually...
but it doesnt explain much, right?

also, what is a uno bridge?
where do i get the automation servers this wiki mentions?
should i install any package?

MS Office apps and OpenOffice have Automation servers built in so you don't have to install anything else. Try the example code.

If you're only working on Windows, that should be all you need, assuming FPC supports COM better than it used to.

A "bridge" in this context would be language bindings to the OpenOffice C++ classes (UNO). With Windows, Automation serves as that bridge and is great because it's pretty much language independent and it's object oriented.

Thanks.

-Phil

thales

  • New Member
  • *
  • Posts: 21
Re: office automation??
« Reply #5 on: August 10, 2009, 10:12:50 pm »
hum... so theorically it should accept the same sintaxis that work with delphi, right? but it doesnt...
for example: (creating an excel file and showing it...)

arq:=createoleobject('excel.application');
arq.visible:=true;

raises an exception on the second line... and the cool thing is, there's nothing inside the error message! just the OK button... ¬¬
that's why i thought of lazarus' interpretation of the automation server...
any tips?

Phil

  • Hero Member
  • *****
  • Posts: 2750
Re: office automation??
« Reply #6 on: August 10, 2009, 10:33:09 pm »
hum... so theorically it should accept the same sintaxis that work with delphi, right? but it doesnt...
for example: (creating an excel file and showing it...)

arq:=createoleobject('excel.application');
arq.visible:=true;

raises an exception on the second line... and the cool thing is, there's nothing inside the error message! just the OK button... ¬¬
that's why i thought of lazarus' interpretation of the automation server...
any tips?

Are you using the latest FPC? 2.2.4 or 2.3.1? As indicated on the Web site, Automation doesn't work with 2.2.2.

"sintaxis" - taxis for sin?

Thanks.

-Phil

thales

  • New Member
  • *
  • Posts: 21
Re: office automation??
« Reply #7 on: August 10, 2009, 10:45:46 pm »
yeah, turns out, i'm using the 2.2.2 version... ¬¬ how can i update it?
it's kinda weird, since i am using the latest lazarus release...

Phil

  • Hero Member
  • *****
  • Posts: 2750
Re: office automation??
« Reply #8 on: August 10, 2009, 10:54:01 pm »
yeah, turns out, i'm using the 2.2.2 version... ¬¬ how can i update it?
it's kinda weird, since i am using the latest lazarus release...

See the Daily Snapshots link.

-Phil

thales

  • New Member
  • *
  • Posts: 21
Re: office automation??
« Reply #9 on: August 11, 2009, 05:16:12 am »
sorry man, i'm kind of a newbie here...

what about the snapshots?
it says it's unsafe to use them... (untested software...)
should i update the compiler?

Leledumbo

  • Hero Member
  • *****
  • Posts: 8111
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: office automation??
« Reply #10 on: August 11, 2009, 10:01:53 am »
Quote
what about the snapshots?
it says it's unsafe to use them... (untested software...)
should i update the compiler?
It's entirely up to you. Some freaks (like me :D) love to use it because you can get more features (+new bugs, of course). And bugs usually get fixed in days after you report (indirect contribution), so why you have to be afraid?

theo

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1890
Re: office automation??
« Reply #11 on: August 11, 2009, 10:15:58 am »
When trying OLE stuff, it's a good idea to have the latest FPC Version.

Try "Lazarus + fpc 2.2.5" http://www.hu.freepascal.org/lazarus/

thales

  • New Member
  • *
  • Posts: 21
Re: office automation??
« Reply #12 on: August 11, 2009, 01:35:02 pm »
It's entirely up to you. Some freaks (like me :D) love to use it because you can get more features (+new bugs, of course). And bugs usually get fixed in days after you report (indirect contribution), so why you have to be afraid?

hum... like i said, i'm new here, and i never used the bugtracker...
(which i probably will...  :D)

When trying OLE stuff, it's a good idea to have the latest FPC Version.
Try "Lazarus + fpc 2.2.5" http://www.hu.freepascal.org/lazarus/

downloading it!
but still, i find it weird because, see... it accepts this:
arq:=createoleobject('excel.application');
which i think is already automation, right?  :o

theo

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1890
Re: office automation??
« Reply #13 on: August 11, 2009, 02:08:09 pm »
but still, i find it weird because, see... it accepts this:
arq:=createoleobject('excel.application');
which i think is already automation, right?  :o

"accept" doesn't mean that it is properly working. ;-)

thales

  • New Member
  • *
  • Posts: 21
Re: office automation??
« Reply #14 on: August 11, 2009, 03:41:41 pm »
hum...
anyway... i installed lazarus + fpc 2.2.5 and i got the same results...

since lazarus is not windows-only, maybe we have to import type libraries for windows apps manually? in delphi it was 'automatic', but delphi is windows-only... does anyone know how to do that?

any tips?