I have a code in VBA that worked perfectly for a long time. Suddenly it stopped working for no reason. Nothing has changed on my side.
I use it to download web pages and store them in strings like this:
Function something() As String
URL = "www..."
Set XMLHTTP = CreateObject("WinHttp.WinHttpRequest.5.1")
XMLHTTP.Open "GET", URL, False
XMLHTTP.send
something = XMLHTTP.responseText
End Function
at XMLHTTP.send I get the following error:
Run-time error '-2147012739 (80072f7d)': An error occurred in the secure channel support
Whats is the meaning of this error and what can be done?
I tried reading about it but it seems that its a generic error and could be many things. Perhaps Microsoft changed some protocols or something similar?
I had this same error:
6/30/2018
I'm running Excel on windows 7,
On a Mac, In Parallels.
This was a very simple fix.
Goto Control Panel,
Click Network and Internet,
Click Network and Sharing Center,
(at the Bottom Left CLICK Internet Options)
Internet Properties Dialog Box will come up,
Click the Advanced Tab
Scroll to bottom and turn on "Use TLS1.2"
(Mine was already Set Prior to receiving the Error)
Click Apply
Here is the link to the downloads need for the proper Windows OS Update file:
http://www.catalog.update.microsoft.com/search.aspx?q=kb3140245
I downloaded and Installed the UpDate from Windows Explorer (File Manager)
Restarted Windows
and ran the VBA.
It ran perfectly
Thanks to Srinath Gudimetla see his link is below for full details:
https://www.linkedin.com/pulse/working-vba-tls-protocol-srinath-gudimetla
Related
Background: Our production environment runs (legacy) vbscript both client- and server-side. So we are still on IE8. We're looking into upgrading client PCs to IE11. One problem we found is our file-downloads-for-display-in-browser no longer works. When clicking on, say, "test.xlsx" on the screen, which then calls a vbscript that does the following:
...
(read blob from database which can be pdf, xls, etc.)
....
If Not objRec.BOF And Not objRec.EOF Then
lngSize = objRec("document").ActualSize
objBlob = objRec("document").GetChunk(lngSize)
Response.ContentType = "application/download"
Response.AddHeader "Content-disposition","attachment; filename=""" + objRec("file_name") + """"
Response.BinaryWrite objBlob
...
we get the prompt:
"Do you want to open or save download_asp?id=1616 from dev.ourintranet.com?"
with options to "Open", "Save", and "Cancel".
Clicking Open does nothing.
Clicking Save opens directory common dialog but hitting Save does nothing.
Clicknig Cancel does nothing.
Why does it not work on IE11 anymore? Thanks a lot!
Client-side VBScript no longer works in IE11 edge mode:
As of Internet Explorer 11, VBScript is considered deprecated and should no longer be used as a scripting language for IE11. Webpages displayed in IE11 mode won't execute VBScript code.
Because VBScript is no longer supported for IE11 mode, the following API features are no longer available to webpages:
The execScript function.
The VBArray object.
The "text/vbs" and "text/vbscript" MIME types (as supported type values for script elements).
Update any pages that currently rely on VBSscript to use JavaScript. If this isn't feasible, try replacing the webpage with an app written in Visual Basic.
For compatibility reasons, VBScript does execute for legacy document modes (IE10 standards mode and earlier), however, this should be considered a temporary solution.
I have very weird issue with some VBA code. The code is InternetExplorer automation and it's really simple: I just need to load page, enter credentials and click on the button on another page (after successful login).
But... My code is not working (but only on one of my machines on AWS). On my local machine this code works fine.
The weird thing is that it seams I have access only to the Document property of the first loaded page (where I need to enter login/password). I mean from MyBrowser.Document property I can see all INPUT fields when I load start page. But after successful login (the IE window is visible) I see same INPUT fields from MyBrowser.Document property! Also (as I said) I have no issues with this code on another maching.
IE Protected mode is disabled (this is IE 11). I think this is some kind of security issue but I can't locate it by myself...
Here is my code:
'MyBrowser is IE instanse
'Here I'm loading start page and input login/password
'Next the browser show me another page where I need to click a button
'But Debug messages show me input fields for the first Form!
Application.Wait (Now + TimeValue("0:00:05"))
Do
DoEvents
Loop Until MyBrowser.ReadyState = READYSTATE_COMPLETE
Set HTMLDoc = MyBrowser.Document
For Each myHTML_Element In HTMLDoc.getElementsByTagName("INPUT")
If myHTML_Element.Type = "submit" And myHTML_Element.Name = "BUTTONNEWJOBS" Then myHTML_Element.Click: Exit For
Debug.Print myHTML_Element.Name
Next
UPDATE
I don't know why but my browser object is always Busy that's why I get old page HTML. I tried to .Stop it but with no luck.
I don't have answer for IE11 automation, just a hint for a path you may choose to walk.
Another Stack Overflow question Getting source of a page after it's rendered in a templating engine? provides some browser automation options.
One of the mentioned tool has currently broken support for IE11 due to a IE11 behavior change, see http://docs.seleniumhq.org/about/platforms.jsp#browsers. The blocking issue has some configuration hints you may find useful.
In my opinion Internet Explorer was ALWAYS the least reliable tool both from the point of view of rendering compatibility, programmability and even the automation problems accross different versions. And although it had improved over the years Internet Explorer is still better to be avoided (from programmer's point of view). Today it is luckily not the only tool available.
So if you just need to get the work done, there are other browsers or browser-like tools that you can use.
If you MUST use IE then you should get your answer at the Internet Explorer Dev Center → Community → Developer forums
EDIT (after comments)
By the symptoms in your question it looks like the browser object is busy because of some dialog box (perhaps a security prompt) is being show to the user. Some links from Google that may help:
required IE configuration from the selenium browser automation engine - https://code.google.com/p/selenium/wiki/InternetExplorerDriver
how to disable Internet Explorer Enhanced Security Configuration - http://4sysops.com/archives/four-ways-to-disable-internet-explorer-enhanced-security-configuration-ie-esc/
Internet Explorer Security Zones and Compatibility View - https://help.blackboard.com/en-us/Learn/9.1_SP_14/Administrator/030_Browser_Support/030_Browser_Support_IE_Issue
set of dialogs that can be manipulated by the iMacros Internet Explorer automation toolkit - http://wiki.imacros.net/Browser_Automation#Dialog_Manager
Rewriting ~1000 lines of code to use another automation interface (or browser) and asking for help at the Microsoft's Internet Explorer Dev Center are IMO still valid options
Based on your following statement
I see same INPUT fields from MyBrowser.Document property!
it would seem that the page hasn't fully loaded. Perhaps it is loading data via AJAX and clicking the submit button shows the exact same page (which would explain why you were seeing the same INPUT fields) while waiting for a response from the server.
An easy way to test this is to wait for a longer period of time (e.g. 30 seconds) and ignoring the value of the browser ReadyState. However a better way would be looping until you find a element on the successful page that isn't on the first page, with a possible timeout of maybe 30 seconds.
I've used Selenium to do some automation and ran into similar problems and had to resort to using Implicit Waits but I'm not sure if VBA as such a feature (as I don't know VBA)
I've write an automated application in VB6 (and also in VB.NET) that opens an HTML documents for printing.
My function works fine, without human interaction.
Now we have put application machine off-line.
When you open an HTML with Ms Word (all versions), it try to download all html internet reference (images, css), but it fails and show me a popup that alert me failed to download CSS and Images.
I've not found an advanced option that deny files download from internet, in Word application and in Ole Word Object.
The problem is that the following code is blocked at third line because wait human interaction clicking on "OK" in popup.
ObjectName = "Word.Application"
Set OleObj = CreateObject(ObjectName)
Set OleDoc = OleObj.Documents.Open(FileIn, False, True ,False, "password") 'Block here
OleDoc.PrintOut PrintToFile:=False, Background:=False
Do you know Word Option, registry option or custom VB or .NET code that exlude popup or deny download associated css or image files from internet?
Help me,
Thanks in advance
Have you tried...
Application.DisplayAlerts = wdAlertsNone
...before trying to open your document?
I don't know if it will take care of this specific error message popup since Word does have a few anti-virus protection popups that can't be turned off. That's one reason why it's less than ideal for a production unattended processing application. I'd strongly recommend looking at some other tools to achieve your project goal.
I want safari to download and save a web page using apple automator. With a Safari window open, I run the following script in AppleScript Editor:
tell application "Safari"
set URL of document 1 to "http://www.python.org"
delay 6
get document 1
delay 6
save document 1 in "/mydir/" & "python" & ".htm"
end tell
Safari displays the correct url, but then I get the following error in safari:
"The document “Python Programming Language – Official Website” could not be saved as “python.htm”."
I click "ok" on that error box and then AppleScript Editor gives me this error in a dialog box:
"AppleScript Error
Safari got an error: AppleEvent handler failed."
AppleScript Editor has a box at the bottom called "Result" and it also displays the following message:
"error "Safari got an error: AppleEvent handler failed." number -10000"
And the web page won't save. I don't know what's causing this b/c I'm 99% sure that I was using this same (or similar) code to save pages in the past.
Strangely, I moved the "get document 1" and "save document 1" lines outside of the "tell application safari" block and it saved the applescript as "python.htm" and it looked all goofy when opened with Firefox. So the problem seems to be that Safari cannot save and not osx generally.
also, I used chmod to change all permissions on the target save directory to all (used 777 argument in bash).
I updated the software restarted several times.
Here's my versions:
Safari: Version 5.1 (6534.50)
OSX Snow Leopard: Version 10.6.8
AppleScript 2.1.2
AppleScript Editor: Version 2.3 (118)
I'm tethered to my cell phone, using it as a mobile access point. I don't know if that matters.
I think this guy got the same error but no answers:
Why does this AppleScript get an "AppleEvent handler failed" error on Mac OS X 10.5 Leopard?
Anybody got a guess? Thanks.
I don't know the real answer, but it has 50+ views and a tumbleweed, so I figured I'd post something.
apparently you're supposed to use curl:
tell application "Safari"
set URL of document 1 to "http://www.python.org"
delay 6
get document 1
set my_html to URL of document 1
end tell
set my_new_file to "/Users/your_user_name/python.htm"
set my_script to "curl " & my_html & " >> " & my_new_file
do shell script my_script
(I saw a post on macscripter and they said this was "the only way to go" so maybe there is no way to use "save as" in Safari and this is a common applescript error but it was not answered b/c this is not an applescript board? Anyway, maybe the original post is supposed to work and I just don't know any better. I figured if people were finding this on the board or through google, an answer may be helpful or maybe the mods just want to delete it if this is an obvious solution).
If I use IE I can visit the website I want and click the 'Next' button and life is good. If I open that same website using the webBrowser control and click the 'Next button I get a javascript error message.
I'm not doing anything in the code to manipulate the website. My goal, eventually, is to have some level of automation; but at this point, I get the javascript error and a pop-up and it screws everything else.
I can hide the JS error from popping up; by setting 'WebBrowser1.ScriptErrorsSuppressed = True' but the page isn't working because of the error.
The client script might be assuming a full browser is present and trying to access part of the browser outside the Document Object Model (DOM) of the page. For example, maybe the client script is trying to display something on the browser's status bar, or trying to modify a toolbar which isn't available in the WebBrowserControl. There could be numerous similar reasons.
If you do not have write-access to the web page in question to try fixing it, then play with WebBrowser Control properties such as ScriptErrorsSuppressed and ObjectForScripting
Try setting WebBrowser1 Silent property to true.
Actually, you are receiving this problem because when you run your site in IE8 or IE9 on your normal internet explorer desktop app, you are getting either IE8 or IE( rendering, depending on which you have installed. However, with the webbrowser control, unless you take the effort to change soem settings in the registry, the default rendering engine used by the webbrowser control is IE7 (if u have 7, 8 or 9 installed) and IE4 (if you have 4, 5 or 6 installed).
This is why you are having the problem, if you want help changing the rendering engine version for your webbrowser control, do a google search as there are many examples on SO, and i have provided this answer in some of my previous posts on this tag/topic. feel free to search or ask me.
Let me know how you go.