开发者

Accessing Label which is drawn on the worksheet

I draw a simple label control directly onto the excel worksheet. B开发者_Python百科ut I can't seem to find any way to access it via code in the VBA editor. Is this even possible?


You may have drawn an ActiveX label or a Forms label. If it was the first label on the sheet then the following code will pick up the default "label1" name and either objActiveXLabel or objFormslabel will refer to your control

You could also experiment recording macros with the VBA recorder when inserting labels as this will give you pointers to the label type, and how to manipulate the label

Dim objActiveXLabel As OLEObject
Dim objFormsLabel As Shape
On Error Resume Next
Set objActiveXLabel = ActiveSheet.OLEObjects("Label1")
Set objFormsLabel = ActiveSheet.Shapes("Label 1")
On Error GoTo 0
If Not objActiveXLabel Is Nothing Then MsgBox "Found an ActiveX label", vbExclamation
If Not objFormsLabel Is Nothing Then MsgBox "Found an Forms label", vbExclamation
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜