在VBA中,可以使用`Now`函数来获取当前日期和时间,或者使用`Date`函数仅获取当前日期。以下是两种方法的示例代码:
使用`Now`函数
```vba
Sub 获取当前日期时间()
Dim currentTime As Date
currentTime = Now
MsgBox "现在的日期时间是:" & currentTime
End Sub
```
使用`Date`函数
```vba
Sub GetCurrentDate()
Dim currentDate As Date
currentDate = Date
MsgBox "当前日期是:" & currentDate
End Sub
```
这两种方法都可以在消息框中显示当前日期。根据你的需求选择其中一个即可。