我有一个访问 URL HTTPS 的 Excel 文件。 URL 作为使用用户名和密码的基本身份验证。
该宏每天早晚运行。它需要它是自动的。我有用户名和密码。
问题是,每次我运行宏时,它都会提示我输入“Windows 安全”。用户名和密码已填满,因为我确实在凭据中添加了此连接。 “Windows安全”只是等待用户点击进入。该宏应该自动运行,不能等待某人单击“确定”。
我确实尝试过 VBS 脚本登录,但它仅在用户在会话中处于活动状态时才有效。看看这个:用于传递用户名和密码的 VBA 代码 https://stackoverflow.com/questions/24879914/vba-code-to-pass-username-password
我也尝试将用户名和密码放入 URL 中,例如:...
如何在没有“Windows 安全”提示的情况下进行连接???
这是我的添加连接功能:
Function GetForcast(DateStart As String, DateEnd As String)
Sheets("Forecast RAW").Select
With Sheets("Forecast RAW").QueryTables.Add(Connection:= _
"URL;https://weather.dtn.com/basic/rest-3.4/obsfcst.wsgi?dataTypeMode=0001&dataType=HourlyForecast&startDate='" & DateStart & "'T00:00:00Z&EndDate='" & DateEnd & "'T00:00:00Z&stationID=KILG" _
, Destination:=range("$A$1"))
.Name = "00Z&stationID=KILG"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = True
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.WebSelectionType = xlEntirePage
.WebFormatting = xlWebFormattingNone
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
'Shell "WScript C:\Temp\Logon.vbs", vbNormalFocus
.Refresh BackgroundQuery:=False
End With
End Function
如果您无法控制远程计算机的安全级别,那么我会采用以下解决方案之一:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)