使用VBA设置系统日期和时间 [英] setting system date and time using VBA
本文介绍了使用VBA设置系统日期和时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
用于Office2007的VBA似乎可以通过以下方式设置系统日期和时间:
VBA for Office2007 seems to give the possibility to set system date and time with:
date = variable
和time = variable
但是,如果我尝试使用该代码:
however, if I try the code:
Dim Datum1
Datum1 = #12. Februar 1985#
Date = Datum1
我收到错误消息权限被拒绝(错误70)",这似乎表明我没有管理员权限,情况并非如此.
I get the error message "Permission denied (Error 70)", which seems to indicate that I have no administrator rights, which is not the case.
有人能指出我正确的方向吗?
Can anybody point me in the right direction?
推荐答案
使用DateSerial和TimeSerial.例如:
Use DateSerial and TimeSerial. For example:
Date = DateSerial(2015, 11, 4) 'For Date changing
Time = TimeSerial(12, 10, 22) 'For Time changing
...或者您可以尝试使用ShellExecute和Date.
...or you can try to use ShellExecute and Date.
这篇关于使用VBA设置系统日期和时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文