【发布时间】:2015-09-04 03:31:12
【问题描述】:
我有一个访问 URL HTTPS 的 Excel 文件。 URL 作为带有用户名和密码的基本身份验证。
这个宏每天早晚都会运行。它需要它是自动的。我有用户名和密码。
问题是每次我运行宏时,它都会提示我“Windows 安全”。用户名和密码已经填满,因为我确实在我的凭据中添加了这个连接。 “windows 安全”只是等待用户点击回车。这个宏应该会自动运行,不能等待有人点击确定。
我确实尝试过使用 VBS 脚本登录,但它仅在用户在会话中处于活动状态时才有效。看到这个: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
【问题讨论】:
-
你解决了吗?我也有同样的问题
-
您是否尝试在您的网址上使用“http”而不是“https”?
-
“我确实尝试过使用 VBS 脚本登录,但它仅在用户在会话中处于活动状态时才有效”是什么意思?你能再解释一下吗...