Option
Explicit
Sub
test_ole()
Dim
names()
As
Variant
Dim
ole
As
OLEObject
Dim
i
As
Long
names = Array(
"Beschriftung-01"
,
"Beschriftung-02"
,
"Beschriftung-03"
)
With
Worksheets(1)
For
Each
ole
In
.OLEObjects
If
TypeName(ole.
Object
) =
"CheckBox"
Then
If
i <= UBound(names)
Then
Debug.Print Format$(i + 1,
"00"
) &
": "
& ole.
Object
.Caption &
" => "
& names(i)
ole.
Object
.Caption = names(i)
i = i + 1
Else
Exit
For
End
If
End
If
Next
If
i > 0
Then
Call
MsgBox(
"Fertig"
, vbInformation)
Else
Call
MsgBox(
"keine Treffer"
, vbInformation)
End
If
End
With
End
Sub
Sub
test_formular()
Dim
names()
As
Variant
Dim
shp
As
Excel.Shape
Dim
i
As
Long
names = Array(
"Beschriftung-01"
,
"Beschriftung-02"
,
"Beschriftung-03"
)
With
Worksheets(1)
For
Each
shp
In
.Shapes
If
shp.Type = msoFormControl
Then
If
shp.FormControlType = xlCheckBox
Then
If
i <= UBound(names)
Then
Debug.Print Format$(i + 1,
"00"
) &
": "
& shp.OLEFormat.
Object
.Caption &
" => "
& names(i)
shp.OLEFormat.
Object
.Caption = names(i)
i = i + 1
Else
Exit
For
End
If
End
If
End
If
Next
If
i > 0
Then
Call
MsgBox(
"Fertig"
, vbInformation)
Else
Call
MsgBox(
"keine Treffer"
, vbInformation)
End
If
End
With
End
Sub