vba 无法在 Office 2013 中使用日期和时间选择器

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/24010526/
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 18:16:27  来源:igfitidea点击:

Cannot use Date and Time Picker in Office 2013

vbadatepickerexcel-2013

提问by Pawe? Czech

Since few days I have tried to apply this ActiveX to my Excel 2013. I made small app for running reports in Excel and I need some way to pick start and end date.

几天以来,我一直尝试将此 ActiveX 应用于我的 Excel 2013。我制作了用于在 Excel 中运行报告的小应用程序,我需要某种方式来选择开始和结束日期。

Easiest way to do it was Date And Time Picker Control which is in %windir%\syswow64\mscomct2.ocx. It worked perfectly at Windows 7 64-bit + Excel 2010 32-bit.

最简单的方法是日期和时间选择器控件,它位于 %windir%\syswow64\mscomct2.ocx。它在 Windows 7 64 位 + Excel 2010 32 位上完美运行。

When I moved my project to other PC with Windows 7 64-bit and Office 2013 32-bit it stopped working. Firstly there was class missing, so I registered Microsoft Windows Common Controls 2 6.0 (SP3) in syswow64 using regsvr32.exe command.

当我将我的项目移动到其他装有 Windows 7 64 位和 Office 2013 32 位的 PC 时,它停止工作。首先是缺少类,所以我使用 regsvr32.exe 命令在 syswow64 中注册了 Microsoft Windows Common Controls 2 6.0 (SP3)。

It did not help - it was keep saying "cannot insert object". Tried another versions of Common Controls (currently SP6), but problem is still there - I can`t put any control to my Excel worksheet.

它没有帮助-一直说“无法插入对象”。尝试了其他版本的 Common Controls(当前为 SP6),但问题仍然存在 - 我无法将任何控件添加到我的 Excel 工作表中。

I`m running out of ideas and tutorials, so maybe some of You had ran into this type of problem and have solution?

我的想法和教程用完了,所以也许你们中的一些人遇到了这种类型的问题并有解决方案?

回答by Profex

It's best that you just abandon your search for a Microsoft solution. They haven't updated the common controls for 64-bit. Your best options are to create your own ActiveX Control by wrapping the Date And Time Picker Control from .Net or communicate using COMand expose the features that you want, or use one of the custom VBA solutions that can be found on Ron de Bruin's Calendar/Date Picker page.

最好放弃对 Microsoft 解决方案的搜索。他们还没有更新 64 位的通用控件。您最好的选择是通过从 .Net 包装日期和时间选择器控件来创建自己的 ActiveX 控件,或者使用 COM 进行通信并公开您想要的功能,或者使用可以在Ron de Bruin 的日历上找到的自定义 VBA 解决方案之一/日期选择器页面

I've used this one - Calendar Control for All Office versions - including Office 2010 64 bit

我用过这个 -所有 Office 版本的日历控件 - 包括 Office 2010 64 位

but this one looks better IMO - A Pop-up Calendar for Excel 2007 and up

但这个看起来更好 IMO - Excel 2007 及更高版本的弹出式日历

Even if you can get it running on your machine, if you work at a large company, like myself, you'll never get IT to deploy the fix to everyone.

即使你可以让它在你的机器上运行,如果你在像我这样的大公司工作,你永远不会让 IT 将修复程序部署到每个人。

Edit: was getting confused with MSCOMCTL.OCX issues

编辑:对 MSCOMCTL.OCX问题感到困惑