Option
Explicit
Dim
coll
As
New
Collection
Sub
Umwandeln()
Dim
shp
As
Shape, tooltips()
Dim
t
As
Single
, l
As
Single
, w
As
Single
, h
As
Single
, c
As
String
, n
As
String
, i
As
Long
tooltips = Array(
"Beschreibung 1"
,
"Beschreibung 2"
,
"Beschreibung 3"
)
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)
i = i + 1
With
.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 = tooltips(i - 1)
End
With
coll.Add
New
axButton
Set
ax = coll(coll.Count)
Set
ax.cb = cb1
End
With
.Visible =
False
.Visible =
True
End
With
End
If
End
If
Next
shp
End
Sub
Sub
Zuweisen()
Dim
shp
As
Shape, btn
As
MSForms.CommandButton, ax
As
axButton
Set
coll =
Nothing
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