vba excel日期选择器控件

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/13470779/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 14:27:51  来源:igfitidea点击:

excel date picker control

excelexcel-vbadatepickerexcel-2010vba

提问by Ole Henrik Skogstr?m

I need to create an in cell date picker for a excel worksheet I'm creating.

我需要为我正在创建的 Excel 工作表创建一个单元格内日期选择器。

I'm trying to follow this tutorial

我正在尝试按照本教程进行操作

However i cant understand how the example is supposed to place a calendar picker in cell A1:C1. In my worksheet, if i paste the code as is, it throws an error. if i try to modify it like so:

但是我无法理解该示例应该如何在单元格中放置日历选择器A1:C1。在我的工作表中,如果我按原样粘贴代码,则会引发错误。如果我尝试像这样修改它:

'Declaration
Public Function AddDateTimePicker(range As range, name As String) As DateTimePicker   

Private Sub ExcelRangeAddDateTimePicker()
Dim DateTimePicker1 As Microsoft.Office.Tools.Excel.Controls.DateTimePicker
DateTimePicker1 = Me.Controls.AddDateTimePicker(Me.range("A1", "C1"), "DateTimePicker1")       
End Sub

I get no result at all...

我一点结果都没有...

Any tip or answer is appreciated :)

任何提示或答案表示赞赏:)

采纳答案by Ole Henrik Skogstr?m

I found a better example for a working Excel 2010 Calander than what i had discovered previously.

我找到了一个比我之前发现的更好的 Excel 2010 Calander 示例。

This Tutorial is really good, and helps you to create a pop up Calander for Excel 2010: http://www.fontstuff.com/vba/vbatut07.htm

本教程非常好,可以帮助您为 Excel 2010 创建一个弹出式日历:http: //www.fontstuff.com/vba/vbatut07.htm

I found it at the bottom of the page linked by brettdj. Thank you :)

我在 brettdj 链接的页面底部找到了它。谢谢 :)

回答by PKanold

This VBA version from Trevor Eyre looks pretty great and is well documented. One line of code opens the VBA form and gets the date:

这个来自 Trevor Eyre 的 VBA 版本看起来非常棒,并且有据可查。一行代码打开 VBA 表单并获取日期:

myDate = CalendarForm.GetDate

http://trevoreyre.com/portfolio/excel-datepicker/

http://trevoreyre.com/portfolio/excel-datepicker/

-OO-

-OO-