2015-10-19 50 views
0

我创建了一个用开始日期,结束日期,接收日期作为标签和每个带有文本框的标签的窗体。由于管理员权限,无法安装日历控件的外接程序。通过excel 2013中的用户窗体日历

我的搜索结束于安装插件以安装Calendar控件6.0,该控件在我的机器上出现错误“访问被拒绝”时失败。

我的用户表单工作正常,用户必须手动输入日期。 如何在此处获得日历弹出窗口或任何其他建议,只需单击在64位上运行的Excel 2013即可输入日期。

感谢您在这里的时间。谢谢。

+0

我自己解决了。非常感谢你:) 如何关闭它? – sameerj

+0

发布答案并接受它;) – ZygD

回答

0
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 
相关问题