setting system date and time using VBA

妖精的绣舞 提交于 2019-12-20 01:52:46

问题


VBA for Office2007 seems to give the possibility to set system date and time with:

date = variable and time = variable

however, if I try the code:

Dim Datum1
Datum1 = #12. Februar 1985#
Date = Datum1

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?


回答1:


Use DateSerial and TimeSerial. For example:

Date = DateSerial(2015, 11, 4)   'For Date changing

Time = TimeSerial(12, 10, 22)    'For Time changing

...or you can try to use ShellExecute and Date.



来源:https://stackoverflow.com/questions/33600897/setting-system-date-and-time-using-vba

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!