I'm using VBA to open an Internet Explorer window, navigate and log into a webpage and download an Excel Spreadsheet. Every bit of the process works fine, but I can't find a way to automate the process of choosing the "save" option everytime I try to download something on IE.
Here's the code I've been using, found it here, I know I can set VBA to send Alt+S automatically, but it won't work when IE is not in focus and I just couldn't find a way on the web that works.
AppActivate "Internet Explorer"
Application.SendKeys "%{S}"
Is there another way to do it? Without Sending Keys? Or a working way to send keys?
I appreciate any help!
Observations: I'm using IE 11 and can't tinker with it's settings, because I'm not the administrator.
Related
I've successfully automatized a process with Open Twebst. (Go through some links, fill the forms and upload images..) So, it helped me to upload images to a HTML page in Internet Explorer 10.
I've just changed my laptop and It has Windows 10 (64bit) and it enables to use only Internet Explorer 11 instead of 10. - Previously the macro was running on Win7 - excel 2013 and IE10 - it was worked perfectly.
Somehow the macro stops when the upload browser window appears. I've already installed the program and added its reference in VBA but I had no luck. I was trying to simulate IE10 but it didn't work. I was also trying to do it in Excel 2013 instead of 2016 but it was the same.
Could someone help me to solve this issue? I searched a lot in this topic and as I can see everyone has the same issue: the VBA can't be able to control that window on his own.
This link contains a tutorial for the method I used:
http://codecentrix.blogspot.com/2009/11/automate-html-file-upload-control.html
HTML tag where I upload: ....input type="file"....
I was trying to modify the security settings in IE11, but it wasn't helped me - I'm not an expert in IE, maybe someone knows how to set it.
I would really appreciate any ideas/ codes.
Many thanks!
Zoltán Báthori
I would like to click on open when a file download dialog appear in IE 11. I found this code http://www.siddharthrout.com/2011/10/23/vbavb-netvb6click-opensavecancel-button-on-ie-download-window/
But this code does not work with IE11. I have also attached the IE11 download dialog box here too. Anyone has any idea, please, help.
You can use Alt+N to focus on the Notification Bar.
And then send {tab} key to navigate to the specific button.
With VBA, you may use Autohotkey.dll or AutoItX3.dll to send these hotkey combinations.
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'm trying to interface with Bloomberg Pro using DDEExecute but I'm having trouble finding a list of valid DDE commands.
In particular what I'm hoping to do right now is enter specific non-character keystrokes (e.g. "right arrow")
I agree with others that API is the way to go, but if for some reason you do not have the data, you can use a few different approaches including DDE or Sendkeys. I don't believe there is a list though, as bloomberg has said "Although the DDE and SendKeys functionality is documented here, we are unable to assist with specific uses of this functionality"
SendKeys method can be used in the following way:
' Activate a Bloomberg Professional Window (Window #1, in this case)
AppActivate "1-BLOOMBERG"
' Send commands to the Bloomberg Professional service Window
SendKeys "{ESC}" & "MSFT US {f8} DES~", True
Additional help on the "SendKeys" methods [Syntax of the keystrokes] can also be found in the MSDN Library - VBA Help Files, as well as in the Add-Ins Help file. This file can be opened from the Windows task bar by clicking the START menu and then Programs|Bloomberg.
The list including right arrow can be found here.
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.