| View previous topic :: View next topic |
| Author |
Message |
ubrewery Newbie

Joined: 26 Aug 2008 Posts: 4
|
Posted: Thu Nov 17, 2011 6:54 am Post subject: Calc, Pictures and macro |
|
|
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 |
|
 |
ubrewery Newbie

Joined: 26 Aug 2008 Posts: 4
|
Posted: Sun Nov 27, 2011 11:39 pm Post subject: Re: Calc, Pictures and macro |
|
|
| 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 |
|
 |
Villeroy Super User


Joined: 04 Oct 2004 Posts: 10065 Location: Germany
|
Posted: Mon Nov 28, 2011 5:40 am Post subject: |
|
|
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 |
|
 |
|
|
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
|