Hallo,
dazu würde man die Proc auslagern:
Option Explicit
Private Sub CommandButton4_Click()
Call Insert_Picture(CommandButton4)
End Sub
Private Sub CommandButton5_Click()
Call Insert_Picture(CommandButton5)
End Sub
Private Sub Insert_Picture(ByRef probjCommandButton As MSForms.CommandButton)
Dim eingabe As String
Dim lngIndex As Long
lngIndex = Mid$(String:=probjCommandButton.Name, Start:=Len(TypeName(probjCommandButton)) + 1)
'open insert picture dialog
Application.Dialogs(xlDialogInsertPicture).Show
With Selection.ShapeRange
.LockAspectRatio = False
.Top = Range("Picture" & lngIndex).Top
.Left = Range("Picture" & lngIndex).Left
.Height = Range("Picture" & lngIndex).Height
.Width = Range("Picture" & lngIndex).Width
End With
'open inputBox with Dialog for figure caption
eingabe = InputBox("Please insert a picture caption")
'transfer data zu caption
Range("Caption" & lngIndex).Value = "Fig. " & lngIndex & ": " & eingabe
End Sub
Gruß,
|