Private Declare PtrSafe Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" _
(ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, _
ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Private Const SW_SHOW = 5
Private Sub ss()
Dim myd As Object
Set myd = CreateObject("Scripting.Dictionary")
myd("昌平区") = "https://tianqi.2345.com/wea_history/60198.htm"
myd("朝阳区") = "https://tianqi.2345.com/wea_history/71141.htm"
myd("东城区") = "https://tianqi.2345.com/wea_history/71445.htm"
myd("大兴区") = "https://tianqi.2345.com/wea_history/60205.htm"
myd("丰台区") = "https://tianqi.2345.com/wea_history/71142.htm"
myd("房山区") = "https://tianqi.2345.com/wea_history/60206.htm"
myd("海淀区") = "https://tianqi.2345.com/wea_history/71144.htm"
myd("怀柔区") = "https://tianqi.2345.com/wea_history/60207.htm"
myd("门头沟区") = "https://tianqi.2345.com/wea_history/60246.htm"
myd("密云区") = "https://tianqi.2345.com/wea_history/60247.htm"
myd("平谷区") = "https://tianqi.2345.com/wea_history/60204.htm"
myd("石景山区") = "https://tianqi.2345.com/wea_history/71143.htm"
myd("顺义区") = "https://tianqi.2345.com/wea_history/60202.htm"
myd("通州区") = "https://tianqi.2345.com/wea_history/71071.htm"
myd("西城区") = "https://tianqi.2345.com/wea_history/71446.htm"
myd("延庆区") = "https://tianqi.2345.com/wea_history/60199.htm"
With Range("A1")
With .Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:= _
"东城区,西城区,通州区,大兴区,密云区, 怀柔区,丰台区,石景山区,门头沟区,昌平区,朝阳区, 海淀区,顺义区,房山区,平谷区,延庆区"
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = ""
.InputMessage = ""
.ErrorMessage = ""
.IMEMode = xlIMEModeNoControl
.ShowInput = True
.ShowError = True
End With
wz = .Value
End With
Call ShellExecute(0, "open", "C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe", myd(wz), "", SW_SHOW)
End Sub
【Excel VBA】edge打开北京 2345历史天气
于 2024-01-25 09:53:10 首次发布
文章描述了如何使用VBA在Excel中创建一个字典来存储北京各城区的天气链接,然后通过ShellExecute函数在MicrosoftEdge中打开指定的天气页面。
摘要由CSDN通过智能技术生成