Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to format a Label of ActiveX controls

Status
Not open for further replies.

feipezi

IS-IT--Management
Aug 10, 2006
316
US
Hi,
When I use the following code to create a Label in an ActiveSheet, and the background of the sheet has the same color as the Label's, say grey, then the Label will have something like a half-frame, i.e., the 2 side of the ractagangle will turn clear or white.
If I do not use the following code, manually create the Label instead, what mentioned above will not happen. I have over 20 reports to take care of and each one has about 10 Labels to be produced. Mannully doing the labels will not be my first choice.
My question is if I can use VBA to create labels without the annoying frame?
Thanks in advance.

Sub CrtLabels()
Dim lb1 As Object
Set lb1 = ActiveSheet.OLEObjects.Add(ClassType:="Forms.Label.1", Link:=False, _
DisplayAsIcon:=False, Left:=6.75, Top:=26.25, Width:=28.5, Height:=14.25)
With lb1.Object
.Caption = "Whatever"
.BackColor = "&H80000003"
.Font.Name = "MS Sans Serif"
.Font.Size = 8.5
End With
End Sub
 
manually create the Label instead, what mentioned above will not happen
Have you tried to look at the code generated by the macro-recorder ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
PHV,
I thought you couldn't get any Macro statements if you manually do something in the Properties window, with the Macro recorder on.
If there is a way, please let me know.
I did make the comparison between the manual one and the VBA one. They have EXACTLY the same properties but they appear differently.
Thanks for the response.
Take care.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top