I’m trying to use the System.Windows.Forms.MonthCalendar control within a VSTO Excel workbook. I want the MonthCalendar to pop up when I click a button in the ribbon, but so far I can’t get the control to display at all.
Private Sub DeliveryDateFromCalendarButton_Click(ByVal sender As System.Object, ByVal e As Microsoft.Office.Tools.Ribbon.RibbonControlEventArgs) Handles DeliveryDateFromCalendarButton.Click
Dim selectedFiscalYear As String = Me.FiscalYearDropDown.SelectedItem.Label
Dim cal As System.Windows.Forms.MonthCalendar = New System.Windows.Forms.MonthCalendar()
cal.Location = New System.Drawing.Point(Cursor.Position.X, Cursor.Position.Y)
cal.Show()
End Sub
The calendar should pop up at the place they clicked, but alas, it fails.
I ended up creating a new System.Windows.Form and adding my calendar to its Controls collection.
Not ideal, so I’m still looking for a solution, but it at least gets me a pop-up calendar.