I have created this sub to do some formatting depending on ActiveControl
CommandButton
Sub ReFormat(Sender As CommandButton)
'Me.PictureBox.Picture = Me.Controls(Sender).Picture
Me.PictureBox.Picture = Sender.Picture
Me.lbl.Caption = Sender.Caption
Sender.PictureCaptionArrangement = acRight
Sender.FontBold = True
Sender.ForeColor = RGB(45, 48, 60)
End Sub
And called it from :
Private Sub Command0_Click()
ReFormat (ActiveControl)
End Sub
It throws this error
I tried this
Sub ReFormat(Sender As Object)
Sub ReFormat(Sender As Control)
Still the same .
What am I doing wrong ?
CodePudding user response:
The parenthesis makes it read-only. Try:
ReFormat ActiveControl