I wrote a macro that creates a Command Button of Type com.sun.star.form.FormButtonType.URL. It is anchored to and has the size of the currently selected cell. The code sets the background color and the font of the button.
When I click on the button, the background color changes to a darker version of the color it was set to.
Is there a way to prevent this?
Here is the part of the code that creates The button, puts it in a Shape, and adds it to the Sheet:
' Create and configure a Command Button with Type=URL
oButton = oDoc.createInstance("com.sun.star.form.component.CommandButton")
oButton.ButtonType = com.sun.star.form.FormButtonType.URL
oButton.Name = sButtonLabel & "_Button"
oButton.Label = sButtonLabel
oButton.TargetURL = sURL
oButton.FocusOnClick = FALSE
oButton.Repeat = FALSE
obutton.BackgroundColor = RGB(255, 255, 215) ' ***** WHY DOES THIS CHANGE (DARKEN) AFTER I CLICK ON IT??? *****
obutton.TextColor = RGB(0, 150, 200)
' oButton.FontName = "Arial" ' Use FontDescriptor instead
' Create and configure a FontDescriptor for the Button and apply it
oFontDesc = oButton.FontDescriptor
' oFontDesc = oDoc.createInstance("com.sun.star.awt.FontDescriptor") ''''' MABXXX WHY DOESN'T THIS WORK???
oFontDesc.Name = "Arial"
oFontDesc.Height = 12
oFontDesc.Weight = 175 ' This is a PERCENTAGE - Default 100% is NORMAL (400), 175% is BOLD (700)
oButton.FontDescriptor = oFontDesc
' Create and configure a Shape to put the Button in
oShape = oDoc.createInstance("com.sun.star.drawing.ControlShape")
oShape.Name = sButtonLabel & "_Shape"
oShape.Control = oButton ' Set the Button as the Control in the Shape
oSheet.DrawPage.add(oShape) ' Add the Shape (that contains the Button) to the Sheet - MUST be ABOVE the following lines
oShape.Size = oCell.Size ' Size the Shape with the Size of the selected Cell
oShape.Position = oCell.Position ' Position the Shape into the selected Cell
oShape.Anchor = oCell ' Anchor the Shape to the selected Cell
oShape.ResizeWithCell = TRUE ' Resize the Shape every time the Cell size changes
oShape.SizeProtect = FALSE ' Allow the Shape to RESIZE, TRUE prevents ResizeWithCell
oShape.MoveProtect = TRUE ' Don't allow the Shape to MOVE