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, Pictures and macro

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


Joined: 26 Aug 2008
Posts: 4

PostPosted: Thu Nov 17, 2011 6:54 am    Post subject: Calc, Pictures and macro Reply with quote

Hi, I've couldn't find a solution even on Pitonyak's book!
I've got lots of calc documents, each one has got a small picture (jpg) in the top left corner of the first sheet.

I need to change that picture.
I've wrote this to insert the new one:

Code:
Dim oFrame
Dim oDisp
Dim oProp(1) as new com.sun.star.beans.PropertyValue
oFrame = ThisComponent.CurrentController.Frame
oDisp = createUnoService("com.sun.star.frame.DispatchHelper")

oDisp.executeDispatch(document, ".uno:Cut", "", 0, Array())
oProp(0).Name = "FileName"
oProp(0).Value = "file:///somewhere/file.jpg"
oProp(1).Name = "AsLink"
oProp(1).Value = False
oDisp.executeDispatch(oFrame, ".uno:InsertGraphic", "", 0, oProp())


But how can I select and remove the old picture first?

Thanks

Paolo
Back to top
View user's profile Send private message
ubrewery
Newbie
Newbie


Joined: 26 Aug 2008
Posts: 4

PostPosted: Sun Nov 27, 2011 11:39 pm    Post subject: Re: Calc, Pictures and macro Reply with quote

ubrewery wrote:
Hi, I've couldn't find a solution even on Pitonyak's book!
I've got lots of calc documents, each one has got a small picture (jpg) in the top left corner of the first sheet.

I need to change that picture.
I've wrote this to insert the new one:

Code:
Dim oFrame
Dim oDisp
Dim oProp(1) as new com.sun.star.beans.PropertyValue
oFrame = ThisComponent.CurrentController.Frame
oDisp = createUnoService("com.sun.star.frame.DispatchHelper")

oDisp.executeDispatch(document, ".uno:Cut", "", 0, Array())
oProp(0).Name = "FileName"
oProp(0).Value = "file:///somewhere/file.jpg"
oProp(1).Name = "AsLink"
oProp(1).Value = False
oDisp.executeDispatch(oFrame, ".uno:InsertGraphic", "", 0, oProp())


But how can I select and remove the old picture first?

Thanks

Paolo



Any idea about getting the focus on a picture in calc documents?

Paolo
Back to top
View user's profile Send private message
Villeroy
Super User
Super User


Joined: 04 Oct 2004
Posts: 10065
Location: Germany

PostPosted: Mon Nov 28, 2011 5:40 am    Post subject: Reply with quote

How about programming a macro? No, dispatches are not the way to go.
_________________
Rest in peace, oooforum.org
Get help on http://forum.openoffice.org
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