Is there any method whereby I can achieve this? I have 15 icon sized images one of which, depending upon need, must be placed in the top right hand corner of a page. Currently when I insert an image, I must then relocate it to it’s rightful place. My issue is that I have my music charts (Nashville Numbers) created such that I can page through the charts on stage using my tablet. At times these is a last minute key change and I need to make a quick note of that, hence the image. I generally don’t have a keyboard or mouse readily available on stage so I need a “quick and dirty” paste of an image of the new key. You can see where I need the image (in blue) here
you can adapt this macro : Insert an image at cursor position - The Document Foundation Wiki
and Assign macro to toolbar
Thanks for that, Am playing with it at, however the doc.createInstance command appears to relate to the Windows API and not Linux, at least it gives me a start. I also note that you still need to place the cursor where you want the image to go, a bit difficult when the document is only made of images. i.e no text. I might need to address that point too.
You’ve pointed me in the right direction, I found this which is closer to what I am attempting to achieve. I now need to create a template with the various key sigs in layers then work out how to how to place the buttons on the toolbar.
Problem not yet solved, but…
Edit it does what I need, I can set up different layers with the appropriate text, now I just need a method to turn off other layers when a particular one is set, Pseudo code
For i = 1 to 13 set visibility off
For i = 3 set visibility on
So far, the button labels are what the macro works on so if I make a label readable then the corresponding layer must have the same name. I could do this using lookup tables but that is a lot of code for a simple process.
(in French, but pretty illustrated)
still adressing what you described in your original post ?
you can upload your document to give readers a better understanding, and a chance to suggest simpler solutions.
I tried that in my original post but it swore at me saying the document was too large. My last reply is closer to what I need. I just need to work out how to turn off all layers other than the main document layer and only one other layer as selected. i.e. layer 1 and layer 6 on and all others off or layer 1 and layer 3 on and all others off…
Not being a French speaker, I may need to see how google translate handles it, from what I can determine it might be another possibility.
This macro does what I need with one caveat, it does not remove a previously inserted shape in the same position. I.e. I run the macro and a shape is inserted. If I run it again another shape is inserted overt the original shape and so on. I need to ensure that there is only one shape on the page in that position.
Sub Cset_Key Dim Doc As Object
Dim Page As Object
Dim RectangleShape As Object
Dim Point As New com.sun.star.awt.Point
Dim Size As New com.sun.star.awt.Size
Point.x = 1000
Point.y = 1000
Size.Width = 1000
Size.Height = 1000
Doc = ThisComponent
Page = Doc.DrawPages(0)
RectangleShape = Doc.createInstance("com.sun.star.drawing.RectangleShape")
RectangleShape.Size = Size
RectangleShape.Position = Point
Page.add(RectangleShape)
'Page.remove(RectangleShape) has no reliable effect here.
RectangleShape.String = "D" ' May only take place after Page.add!
' I change the letter "D" to another letter for subsequent testing
RectangleShape.TextVerticalAdjust = com.sun.star.drawing.TextVerticalAdjust.TOP
RectangleShape.TextHorizontalAdjust = com.sun.star.drawing.TextHorizontalAdjust.LEFT
RectangleShape.TextLeftDistance = 300
RectangleShape.TextRightDistance = 300
RectangleShape.TextUpperDistance = 150
RectangleShape.TextLowerDistance = 300
End Sub
I’ve tried Page.remove(RectangleShape) to delete the existing shape before adding the new one but that does not seem to work reliably. I could just keep adding shape after shape but that would be unwieldy and unnecessarily bloat the document.