View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
NickHK NickHK is offline
external usenet poster
 
Posts: 4,391
Default Adjust Windows Date/Time from Excel VBA

Chris,
I would imagine the SetSystemTime API. However, I would hope the user has
OK'd this change before you make the call.

<From API-Guide: http://www.allapi.net/
The SetSystemTime function sets the current system time and date. The system
time is expressed in Coordinated Universal Time (UTC).

Private Type SYSTEMTIME
wYear As Integer
wMonth As Integer
wDayOfWeek As Integer
wDay As Integer
wHour As Integer
wMinute As Integer
wSecond As Integer
wMilliseconds As Integer
End Type

Private Declare Function SetSystemTime Lib "kernel32" (lpSystemTime As
SYSTEMTIME) As Long

Private Sub Form_Load()
Dim lpSystemTime As SYSTEMTIME
lpSystemTime.wYear = 2000
lpSystemTime.wMonth = 1
'Note: The wDayOfWeek member of the SYSTEMTIME structure is ignored.
lpSystemTime.wDayOfWeek = -1
lpSystemTime.wDay = 24
lpSystemTime.wHour = 23
lpSystemTime.wMinute = 26
lpSystemTime.wSecond = 0
lpSystemTime.wMilliseconds = 0
'set the new time
SetSystemTime lpSystemTime
End Sub

</From API-Guide: http://www.allapi.net/

NickHK

"Chris L" wrote in message
...
Hi,

Is there any method to adjust Windows Date/Time from Excel VBA?

Regards,
Chris