Share via

VBA - Modify System Date / Time ?

Anonymous
2018-08-05T02:11:41+00:00

I have searched the Internet, this forum and many other forums re: VBA Excel to modify the system date and time.

Does anyone have sample VBA code they are willing to share that will modify the system date and time ?

Thanks.

Microsoft 365 and Office | Excel | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

Answer accepted by question author

Anonymous
2018-08-05T09:29:21+00:00

Hi,

To do this you need to be running Excel as an Administrator or you will get a RunTime Error 70 'Permission denied'

To run as adminsitrator right click the Excel icon - click 'More' and run as administrator. You can then change the system date with:-

Sub ChangeClkDate()

Date = DateSerial(2018, 8, 5)

End Sub

and the time with

Sub ChangeClkTime()

Time = TimeSerial(14, 0, 0)

End Sub

Note. Despite being able to do it, I would need a very compelling reason to do so. Fiddling with the system can have effects that may not have been anticipated.

Was this answer helpful?

2 people found this answer helpful.
0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Anonymous
    2018-08-05T15:49:58+00:00

    Mike :

    Thanks for the answer. Just what I was seeking.

    Was this answer helpful?

    0 comments No comments