简体   繁体   English

VBA Office 365 中的日期

[英]VBA Date in Office 365

I created project in VBA Office 2016 32bit and now I am trying running this in Office 365 32-bit (WIN10) and of course I had problem with DataPicker (solved) but now during running code I have error "Complie error: Can't find project or liberary".我在 VBA Office 2016 32 位中创建了项目,现在我正在尝试在 Office 365 32 位(WIN10)中运行它,当然我在使用 DataPicker 时遇到了问题(已解决),但现在在运行代码时出现错误“编译错误:不能查找项目或库”。 Problem is this:问题是这样的:

currentMonth = Month(Date)

Do you have idea why "Date" can't show me today's date?你知道为什么“日期”不能显示今天的日期吗? In Excel 2016 no problems.在 Excel 2016 中没有问题。

Date is not defined here.此处未定义日期。 Is it defined elsewhere?是在别处定义的吗? Seems like Date has been redefined.似乎日期已被重新定义。

This code will work for earlier versions too:此代码也适用于早期版本:

Option Explicit

Sub test()
  Dim theDate as Date
  Dim currentMonth As Integer

  theDate = Now()
  currentMonth = Month(theDate)
  Debug.Print currentMonth
End Sub

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM