ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Error with Calendar object and CommandButton (https://www.excelbanter.com/excel-programming/373224-error-calendar-object-commandbutton.html)

Morris[_2_]

Error with Calendar object and CommandButton
 
Hi, I have never worked with calendar object yet, so here's my
question:

Private Sub Workbook_Open()
CommandButton1.Caption = "Import the list of matches from " &
Calendar1.Value
End Sub

Run-time error '424':
Object required.


Why...?


Muhammed Rafeek M

Error with Calendar object and CommandButton
 
i think u have not inserted calendar...

"Morris" wrote:

Hi, I have never worked with calendar object yet, so here's my
question:

Private Sub Workbook_Open()
CommandButton1.Caption = "Import the list of matches from " &
Calendar1.Value
End Sub

Run-time error '424':
Object required.


Why...?



Norman Jones

Error with Calendar object and CommandButton
 
Hi Morris,

Try something like:

'=============
Private Sub Workbook_Open()
Dim SH As Worksheet
Dim myCB As OLEObject
Dim myCal As OLEObject

Set SH = Me.Sheets("Sheet2") '<<==== CHANGE

Set myCB = SH.OLEObjects("CommandButton1")
Set myCal = SH.OLEObjects("Calendar1")

myCB.Object.Caption = "Import the list of matches from " _
& myCal.Object.Value
End Sub
'<<=============


---
Regards,
Norman


"Morris" wrote in message
ps.com...
Hi, I have never worked with calendar object yet, so here's my
question:

Private Sub Workbook_Open()
CommandButton1.Caption = "Import the list of matches from " &
Calendar1.Value
End Sub

Run-time error '424':
Object required.


Why...?




Morris[_2_]

Error with Calendar object and CommandButton
 

Norman Jones wrote:
Hi Morris,

Try something like:

'=============
Private Sub Workbook_Open()
Dim SH As Worksheet
Dim myCB As OLEObject
Dim myCal As OLEObject

Set SH = Me.Sheets("Sheet2") '<<==== CHANGE

Set myCB = SH.OLEObjects("CommandButton1")
Set myCal = SH.OLEObjects("Calendar1")

myCB.Object.Caption = "Import the list of matches from " _
& myCal.Object.Value
End Sub
'<<=============


---
Regards,
Norman


Thanks Norman, it is working now :)

Muhameed: funny guess :)



All times are GMT +1. The time now is 04:40 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com