Option
Explicit
Dim
coll
As
New
Collection
Sub
Umwandeln()
Dim
shp
As
Shape, tooltip
As
String
Dim
t
As
Single
, l
As
Single
, w
As
Single
, h
As
Single
, c
As
String
, n
As
String
tooltip =
"Test"
Dim
cb1
As
MSForms.CommandButton
Dim
ax
As
axButton
For
Each
shp
In
ActiveSheet.Shapes
If
shp.Type = msoOLEControlObject
Then
If
shp.OLEFormat.progID =
"Forms.CommandButton.1"
Then
With
shp
t = .Top
l = .Left
w = .Width
h = .Height
c = .OLEFormat.
Object
.
Object
.Caption
n = .Name
.Delete
End
With
With
ActiveSheet.Shapes.AddOLEObject(
"Forms.Frame.1"
, Left:=l, Top:=t, Width:=w, Height:=h).OLEFormat.
Object
.
Object
.Caption =
""
.BorderStyle = 1
.BorderStyle = 0
Set
cb1 = .Controls.Add(
"Forms.CommandButton.1"
, n)
With
cb1
.Width = w
.Height = h
.Caption = c
.ControlTipText = tooltip
End
With
coll.Add
New
axButton
Set
ax = coll(coll.Count)
Set
ax.cb = cb1
End
With
End
If
End
If
Next
shp
End
Sub
Sub
Zuweisen()
Dim
shp
As
Shape, btn
As
MSForms.CommandButton, ax
As
axButton
For
Each
shp
In
ActiveSheet.Shapes
If
shp.Type = msoOLEControlObject
Then
If
shp.OLEFormat.progID =
"Forms.Frame.1"
Then
For
Each
btn
In
shp.OLEFormat.
Object
.
Object
.Controls
coll.Add
New
axButton
Set
ax = coll(coll.Count)
Set
ax.cb = btn
Next
btn
End
If
End
If
Next
shp
End
Sub