insert label in worksheet

S

sune

Hello

I try to insert some labels in a worksheet and it works but I can't
change BackStyle to fmBackStyletransparent.

I use this code to insert the labels
ActiveSheet.OLEObjects.Add(ClassType:="Forms.Label.1", Link:=False, _
DisplayAsIcon:=False, Left:=yy, Top:=xx, Width:=102.75, Height:=
_
69.75).Name = "newLabel" & yy & xx

After I insert them I need to set BackStyle to fmBackStyletransparent
and later, if it's possible, I want to delete them.
Is there solution for that?
Sune

*** Sent via Developersdex http://www.developersdex.com ***
 
J

JLGWhiz

To set it manually, you need to be in design mode. Click the icon with the
triangle and ruler. Then right click the label and select Format Object,
then click on the Colors and Lines tab. To delete the label manually, you
will also need to be in design mode.
 
J

JLGWhiz

I couldn't get the background color manually or by code, but that does not
mean it can't be done, just that I don't know how. I did get it to delete by
code. See below.

Sub dl()
ActiveSheet.OLEObjects.Add(ClassType:="Forms.Label.1", Link:=False, _
DisplayAsIcon:=False, Left:=yy, Top:=xx, Width:=102.75, _
Height:=69.75).Name = "newLabel" & yy & xx
ActiveSheet.OLEObjects("newLabel").Delete
End Sub
 
J

JLGWhiz

Well, I could not find a way to change the BackStyle to Opaque or
Transparent, but here is the method to put a color in it.

Sub dl()
ActiveSheet.OLEObjects.Add(ClassType:="Forms.Label.1", Link:=False, _
DisplayAsIcon:=False, Left:=yy, Top:=xx, Width:=102.75, _
Height:=69.75).Name = "newLabel"
For Each obj In Sheets(1).OLEObjects
Next
With Sheets(1).OLEObjects("newLabel").Object
.BackColor = RGB(25, 125, 255)
End With
MsgBox "Observe"
Sheets(1).OLEObjects("newLabel").Delete
End Sub
 
J

JLGWhiz

P.S. The message box is only to pause the macro so you can see the color.
It is not essential to the code.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top