OpenOffice.org Forum at OOoForum.orgThe OpenOffice.org Forum
 
 [Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register
 [Profile]   [Log in to check your private messages]   [Log in

Calc automation - insert OLE object

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API
View previous topic :: View next topic  
Author Message
fm75
Newbie
Newbie


Joined: 15 Feb 2011
Posts: 2

PostPosted: Wed Feb 16, 2011 8:27 am    Post subject: Calc automation - insert OLE object Reply with quote

Hi everyone

One customer of mine asked me to modify an old VB6 software in order to automate OpenOffice Calc. This software use an .ODS template file and produce an .ODS file merging cell ranges with external data. This VB6 software already perform this task using MS Excel.

For unchangeable reasons the software has to take a portion of the original .ODS file, save it in a temporary .ODS file, then import the temporary file into the final one. This action is the same achieved selecting "Insert - OLE Object" from the Calc GUI.

I tried to automate this task using all the methods i was able to find on the net, with no success. I can't find snippets or examples to do that thing from a VB6 program.

Is there someone out there that knows how to include a Calc file into another Calc file via API (OLE Object style) in VB6? I need to automate all the passages: the path of the temporary file and the cell position of the target file where I need to insert it, the width and the height of the inserted file, and I need that the inserted file remains there even if the temporary file is deleted.

Thanks to all
M.
Back to top
View user's profile Send private message
pitonyak
Administrator
Administrator


Joined: 09 Mar 2004
Posts: 3655
Location: Columbus, Ohio, USA

PostPosted: Wed Feb 16, 2011 9:42 pm    Post subject: Reply with quote

never done it......

First, I think that you need the CLSID of a Calc document, the usual method to obtain is to embed one and then inspect it. The following link claims that it is "47BBB4CB-CE4C-4E80-a591-42d9ae74950f "

http://www.oooforum.org/forum/viewtopic.phtml?t=22131

See also:

http://www.oooforum.org/forum/viewtopic.phtml?t=11750&highlight=clsid
http://user.services.openoffice.org/en/forum/viewtopic.php?f=45&t=14342&start=0
http://www.oooforum.org/forum/viewtopic.phtml?t=48271&highlight=ole
http://www.oooforum.org/forum/viewtopic.phtml?t=22845&highlight=ole
http://www.oooforum.org/forum/viewtopic.phtml?t=61104
_________________
--
Andrew Pitonyak
http://www.pitonyak.org/oo.php
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address
fm75
Newbie
Newbie


Joined: 15 Feb 2011
Posts: 2

PostPosted: Thu Feb 24, 2011 12:18 am    Post subject: Reply with quote

Andrew, thank you very much.

I already found and tried the links you suggested, but without luck.

I think the best way is the ole2shape method with the clsid, but sadly i'm not able to write some running code: no errors but at the same time no ole object is visibile in the master sheet.

I tried arealinks also, but with the same results.

Anyone out there ever tried this automation task in VB6?


Thanks to all
M.
Back to top
View user's profile Send private message
hffm
Power User
Power User


Joined: 22 Jul 2005
Posts: 52
Location: GERARDMER FRANCE

PostPosted: Thu Feb 24, 2011 1:44 am    Post subject: Reply with quote

Hello,
Inserting a Writer doc in an other Writer doc is easy in VB6. I don't konw for Calc but I think it's similar. Maybe I can help you, but for the moment I really don't have time. Contact me after beginning of March: I will see what I can do for you.
Back to top
View user's profile Send private message Visit poster's website
ms777
Super User
Super User


Joined: 07 Feb 2004
Posts: 1355

PostPosted: Thu Feb 24, 2011 2:50 pm    Post subject: Reply with quote

Hi,

the following inserts a calc file into the open calc doc.

Good luck,

ms777

Code:
REM  *****  BASIC  *****

Sub Main
  oDoc = ThisComponent
  oSheet = ThisComponent.sheets.getByIndex(0)
  oDP = oSheet.DrawPage

  oOleShape = oDoc.createInstance("com.sun.star.drawing.OLE2Shape")
 
  Dim aPosition as new com.sun.star.awt.Point
  Dim aSize as new com.sun.star.awt.Size

  aPosition.X = 100
  aPosition.Y = 100
  aSize.Width = 10000
  aSize.Height = 10000

  oDP.add(oOleShape)
  oOleShape.setPosition(aPosition)
  oOleShape.setSize(aSize)

  oOleShape.LinkUrl = ConvertToUrl("yourfile.ods")

end Sub
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group