如何在Excel中找到用户的时区偏移量 [英] How can I find user's time zone offset in excel
本文介绍了如何在Excel中找到用户的时区偏移量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用Excel宏来生成RSS提要.用户的时区偏移量需要输入RSS feed的字段.如何在excel宏函数中以编程方式执行此操作?
I am using an excel macro to generate an RSS feed. The user's timezone offset needs to go in the field of the RSS feed. How can I do this programatically in the excel macro function?
推荐答案
将以下代码粘贴到Excel中的模块中:
Paste the following code into a module in Excel:
Private Declare Function GetTimeZoneInformationAny Lib "kernel32" Alias _
"GetTimeZoneInformation" (buffer As Any) As Long
Function GetTimeZone() As Single
Dim retval As Long
Dim buffer(0 To 42) As Long
Const TIME_ZONE_ID_INVALID = &HFFFFFFFF
Const TIME_ZONE_ID_UNKNOWN = 0
Const TIME_ZONE_ID_STANDARD = 1
Const TIME_ZONE_ID_DAYLIGHT = 2
retval = GetTimeZoneInformationAny(buffer(0))
Select Case retval
Case TIME_ZONE_ID_INVALID
GetTimeZone = 0
Case TIME_ZONE_ID_STANDARD, TIME_ZONE_ID_UNKNOWN
GetTimeZone = (buffer(0) + buffer(21)) / -60
Case TIME_ZONE_ID_DAYLIGHT
GetTimeZone = (buffer(0) + buffer(42)) / -60
Case Else
GetTimeZone = 0
End Select
End Function
(来自 http://binaryworld.net/Main/CodeDetail.aspx?CodeId= 152 )
这篇关于如何在Excel中找到用户的时区偏移量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文