Excel VBA,出现提示"Windows安全性"访问URL时 [英] Excel VBA, I get a prompt "Windows security" when accessing an URL
问题描述
我有一个访问URL HTTPS的Excel文件.该URL作为具有用户名和密码的基本身份验证.
I Have an Excel file that access an URL HTTPS. The URL as a basic authentication with username and password.
该宏每天早晚运行.它需要是自动的.我有用户名和密码.
This macro is running every morning and night. It need it to be AUTOMATIC. I have the username and password.
问题在于,每次我运行宏时,都会提示我"Windows安全性".用户名和密码已经填满,因为我确实在凭据中添加了此连接. "Windows安全性"仅等待用户单击Enter.该宏应自动运行,并且不能等待某人单击确定".
The problem is that each time I run the macro, it Prompt me for the "Windows security". The user name and password is already fill up because I did add this connection in my credential. The "windows security" just wait for a user to click enter. This macro should run automaticly and can't wait for someone to click OK.
我确实尝试过VBS脚本登录,但是仅当用户在会话中处于活动状态时它才起作用.参见:传递用户名&的VBA代码密码
I did try VBS Script to login but it only work when user is active on the session. See this : VBA code to pass username & password
我也曾尝试将用户名和密码放在URL中,例如:...
I did also try to put the username and password in the URL like : ...
如何在没有"Windows安全性"提示的情况下进行连接??
How I connect without the "Windows Security" Prompt???
这里是我的添加连接功能:
Here my add connection function :
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
推荐答案
有时浏览器的安全性是个问题,因此您可以这样尝试并声明Internet Explorer;
sometimes the security on the browser security is the issue so you can try and and declare Internet explorer as so;
将IE视作新的InternetexplorerMedium
Dim IE as New InternetexplorerMedium
或
尝试在开发人员选项下降低宏安全性
try decreasing macro security under the developer options
或
转到Internet选项并降低安全级别,但要警告这很危险,通常不建议
go to internet options and decrease the security level but be warned this is dangerous and is not usually recommended
如果您需要更多帮助,可以给我发电子邮件howtovba@gmail.com
if you need more assistance you can email me on howtovba@gmail.com
或进入我的youtube页面,并在您希望通过 https://www.youtube.com/watch?v=hfAhmae4iqA
or go my youtube page and leave a comment on what youd like a video on to be assisted with https://www.youtube.com/watch?v=hfAhmae4iqA
这篇关于Excel VBA,出现提示"Windows安全性"访问URL时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!