|
楼主 |
发表于 2024-7-28 11:11
|
显示全部楼层
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
本帖最后由 wcj6376tcp 于 2024-7-28 12:50 编辑
啥意思,不可能吧
Sub holiday() '获取法定节假日 '
Dim ar(1 To 24, 1 To 31), dt As Date, r As Long, c As Long
Dim oDom As Object, oWin As Object, y As Long, md As String
y = Year(Now())
Set oDom = CreateObject("HtmlFile")
Set oWin = oDom.parentWindow
With CreateObject("Msxml2.XMLHTTP")
.Open "GET", "https://timor.tech/api/holiday/year/" & y, False
.send
oWin.execScript "jsDict=" & .ResponseText & ".holiday"
End With
On Error Resume Next
For dt = DateValue(y & "/1/1") To DateValue(y & "/12/31")
r = Month(dt) * 2
c = Day(dt)
md = Format(dt, "mm-dd")
ar(r - 1, c) = dt
ar(r, c) = oWin.eval("jsDict['" & md & "'].name")
If Weekday(dt, vbMonday) > 5 Then If ar(r, c) = "" Then ar(r, c) = Format(dt, "aaaa")
If ar(r, c) Like "*补班" Then ar(r, c) = "补班" 'ChrW(9785)
Next
With Range("A2")
.CurrentRegion.Clear
With .Resize(UBound(ar), UBound(ar, 2))
.Value = ar
.Font.Size = 10
.HorizontalAlignment = xlCenter
.Borders.LineStyle = xlContinuous
End With
End With
Range("A2:AE25").NumberFormatLocal = "yyyy-mm-dd;@"
Set oWin = Nothing
Set oDom = Nothing
Err.Clear
Beep
End Sub
|
|