【问题标题】:calendar through userform in excel 2013通过excel 2013中的用户表单日历
【发布时间】:2015-10-19 10:23:06
【问题描述】:
我创建了一个用户表单,其中包含开始日期、结束日期、接收日期作为标签,每个标签都有一个文本框。由于管理员权限,无法安装日历控制插件。
我的搜索以安装插件结束,以安装日历控件 6.0,但在我的机器上失败并出现错误“访问被拒绝”。
我的用户表单工作正常,用户必须手动输入日期。
怎么办 我只需单击在 64 位上运行的 Excel 2013,即可在此处弹出日历或输入日期的任何其他建议。
感谢您在这里度过的时光。谢谢你。
【问题讨论】:
标签:
vba
calendar
excel-2013
userform
【解决方案1】:
Function my_date_selection(ByVal d As Variant) As Date
If Not IsDate(d) Then GoTo L1 'Exit Function
If IsDate(d) = True Then
Load calendar
calendar.SelectedDayNumber = Day(d)
calendar.SelectedMonthNumber = Month(d)
calendar.SelectedYearNumber = Year(d)
End If
L1:
calendar.Show
If calendar.SelectedDayNumber = 0 And _
calendar.SelectedMonthNumber = 0 And _
calendar.SelectedYearNumber = 0 Then
my_date_selection = Date
' user click on the cancel button in the calendar control therefore do nothing
Else
my_date_selection = DateSerial(calendar.SelectedYearNumber, _
calendar.SelectedMonthNumber, _
calendar.SelectedDayNumber)
' my_date_selection = Format(my_date_selection, "DD-MMM-YYYY")
End If
' If my_date_selection < Date Then MsgBox "Invalid Date.": GoTo l1
Unload calendar
End Function