AW: Jetzt neuer Fehler ...
17.07.2019 20:09:47
Dieter(Drummer)
Hallo Karin,
jetz taucht neuer Fehler bei Abbrechen auf: Laufzeitfehler 424, Objekt erforderlich und selbe Zeile wird gelb markiert.
Hier mein jetziger Code mit deiner neuen Änderung:
Sub SchalterErstellen()
' Makro zum Erstellen eines CommandButtons
Dim cmbSchalter As MSForms.CommandButton
Dim rngZelle As Range
Dim lng_id As Long
inZaehler = 0
On Error Resume Next
Set rngZelle = Application.InputBox("Zelle für Button auswählen", , , , , , , 8)
On Error GoTo 0
If Not rngZelle Is Nothing Then
lng_id = Application.InputBox("ID?", , , , , , , 1)
If lng_id 0 Then
With Worksheets("Tabelle1")
Application.ScreenUpdating = False
For Each ooElement In .OLEObjects
If ooElement.progID = "Forms.CommandButton.1" Then inZaehler = inZaehler + _
1
Next ooElement
.OLEObjects.Add "Forms.CommandButton.1"
Set ooElement = .OLEObjects(.OLEObjects.Count)
With ooElement
.Object.Caption = " CommandButton" & inZaehler + 1
.Top = rngZelle.Top
.Left = rngZelle.Left
.Width = 125
.Height = 31
.Object.PicturePosition = 1
End With
ooElement.Object.TakeFocusOnClick = False
End With
Application.OnTime Now + TimeValue("00:00:01"), "InitSchalter"
On Error Resume Next
Set ooElement.Object.Picture = Application.CommandBars.FindControl(ID:=lng_id). _
Picture
On Error GoTo 0
End If
End If
Application.ScreenUpdating = True
End Sub
Gruß, Dieter(Drummer)