Page 1 of 1

[Solved]How to change selected picture attributes with macro

Posted: Wed May 14, 2008 2:36 pm
by Paddy Landau
I have dozens of pictures, and I need to change their attributes in exactly the same way each time (change to a specific size; change the position to centred on the page; wrap-through and in background). I need to do this with new pictures every month.

Creating a macro and assigning it to a key (e.g. Ctrl-F) would mean that I could simply select the picture and press the key, which would save me ages.

I've tried recording a macro (Tools, Macros, Record Macro). But, when I press "Stop Recording", it doesn't record the attribute changes.

I've been going through the BASIC Programming Guide, trying to figure out how to write it by hand. Unfortunately, I can't figure out how to access the currently-selected picture and modify its attributes.

Can someone help please either by pointing to where this is documented, or by showing me how to program the macro?

I'm using OO 2.4.0 on Windows Vista.

Thanks.

Re: How to change selected picture attributes with macro

Posted: Wed May 14, 2008 9:03 pm
by JohnV
This should get you started.

Code: Select all

Sub Main
oDoc = ThisComponent
oPic = oDoc.CurrentSelection
'xray oPic
oPic.Height = 2000
oPic.Width = 2000
oPic.HoriOrient = 2
oPic.TextWrap = 1
End Sub

Re: How to change selected picture attributes with macro

Posted: Fri May 16, 2008 11:58 am
by Paddy Landau
Thanks for that.

I'm trying to get my head around how to save it!

I'll post back here once I've succeeded.

Re: How to change selected picture attributes with macro

Posted: Fri May 16, 2008 12:15 pm
by Paddy Landau
JohnV wrote:This should get you started. ...
Thanks, John, much appreciated.

I've saved that and changed the sizes to my required sizes.

Now, where is this all documented, so that I can make the other changes (e.g. "In background")?

Re: How to change selected picture attributes with macro

Posted: Tue May 20, 2008 5:40 pm
by JohnV
Get the Xray utility to examine the properties and methods of an object.
http://ooomacros.org/dev.php#101416

Add the line "oPic.Opaque = false" for in background.

Re: How to change selected picture attributes with macro

Posted: Wed May 21, 2008 11:02 am
by Paddy Landau
That X-Ray Tool is brilliant! Thanks for pointing it out, John.

There are some properties that I don't understand (such as HoriOrientRelation), so I'll get into the documentation and search for them.

I have my macro working now, and looking forward (sort of) to when I need to write another.