Upgrading From IE to EDGE - excel

I need VBA Code translation for Edge.
I’m in a Window10/Excel 16 environment. I have been using Internet Explorer (IE) when I scrape data from websites.
Now, I am needing to upgrade to Microsoft Edge. I am having to translate some code and I am finding I need some help.
I used to call the URL https://www.azblue.com/individualsandfamilies/ using “IE.navigate”. Ex:
IE.navigate "https://www.azblue.com/individualsandfamilies/"
But, what I cannot figure out is how to use these other lines of Code with Edge. Here are a 3 lines of code (disjointed) that I use often and need to know the syntax translation for Edge:
IE.document.getElementById("lockedcontent_0_maincolumn_2_twocolumn2fb4d204091d44aa08196ef423877fd9f_0_ToolbarUsernameControl").Focus
IE.document.getElementById("lockedcontent_0_maincolumn_2_twocolumn2fb4d204091d44aa08196ef423877fd9f_0_ToolbarUsernameControl").Value = "MyUserName"
IE.document.Focus
Of course, any help is greatly appreciated
Thanks!

Microsoft Edge browser doesn't support the COM automation interface that used in VBA. If you want to automate Microsoft Edge, you should use WebDriver.
To get started using WebDriver, you will need to download a testing framework of your choice along with an appropriate language binding and the MicrosoftWebDriver server.
We usually use Selenium and you could download the language binding in this page. At the same time, you could download Microsof Edge WebDriver in this page.
Reference link: Will Microsoft Edge support COM automation (InternetExplorer object)?

Related

How Can I Use Selenium in Excel Without SeleniumBasic?

I created a tool on the job using Excel, VBA and SeleniumBasic to drive Chrome or Edge to go to a company web page and enter some data. The tool works well, but when I requested that it be distributed to a wider audience, I was told that although Selenium is approved for use on company networks, SeleniumBasic is not.
So my question is, is it possible/easy to drive Selenium directly with VBA and avoid having to use SeleniumBasic? The approval process for FOSS is not easy and would take too long, so I think I have to find a workaround.

Relatve URL in distant file (XLS)

I have a problem at my job.
I am totally dependent on a website which must certainly date from the eighties ...
In one of the web pages, there is a link to download an excel file (xls). Let's say for example http://example.excel.xls
In this file, there are hyperlinks to other files (sometimes i think the death penalty is a good thing! ^^).
These links are relative :'( (for example \myfile.pdf)
Internet explorer, strangely, are correcting these links by transforming them in absolute path (http://example.myfile.pdf)
Other browsers (chrome, firefox, even the old edge) don't do it natively. By clicking on the link, we arrive in the local cache, where of course there arenot my files ...
I will soon have to remove IE from computers.
I had considered sending a bombshell on the administrators of this website, but afraid of legal repercussions :)
Is it possible, via settings, an addon or whatever, to make one of the browsers behave in the same way as IE?
I am very grateful for the help you will give me
You had asked,"Is it possible, via settings, an addon or whatever, to make one of the browsers behave in the same way as IE?"
I suggest you make a test with the MS Edge (Chromium) browser.
The MS Edge (Chromium) browser comes with the IE mode feature.
IE mode on Microsoft Edge makes it easy to use all of the sites your organization needs in a single browser. It uses the integrated Chromium engine for modern sites, and it uses the Trident MSHTML engine from Internet Explorer 11 (IE11) for legacy sites.
To configure IE mode, I suggest you refer to Configure IE mode policies. You can refer to the document and configure the necessary policies to enable the IE mode.
It can help you to load your legacy site in the Edge browser using the IE mode which can help you to fix the said issue.

Get already opened Edge (not IE) browser window(s) and scrape contents

I used to be able to find all open IE windows via VBA and was able to access one of the already-opened page's contents in Excel with the objShell object mechanism. I didn't--and don't need--direct "control" (automation) of the browser in terms of pushing buttons, opening urls, etc.
I know automation of Edge is not possible just using VBA, but is there any ability to simply 1.) get a list of MS EDGE open windows and 2.) retrieve the elements within a given (already opened) window without resorting to downloading drivers and utilities like Selenium?
As Tim Williams had informed you there is no COM interface available for the Edge browser.
Microsoft has not provided any way to automate the Edge browser using VBA automation.
So, there is no way to fetch the already opened instance of the Edge browser and retrieve elements with the help of VBA.
I suggest you use the officially recommended way Selenium Web Driver to automate the Edge browser.
I have seen that you want to avoid the Selenium Web Driver approach but at present, this is the only way available to automate the Edge browser.
If you are having any issues with the Selenium Web Driver approach then you can inform us about it. We can try to provide suggestions for it.
Thanks for your understanding.
Please note: I'm the author of this software
You can connect to active instances of Edge with IE mode using Internet Controls for Edge: https://pomio.dk/internet-controls-for-edge/.
Internet Controls for Edge is a COM component and it exposes the same APIs as Microsoft Internet Controls (for Internet Explorer), so if you've already created some automations of Internet Explorer (using Microsoft Internet Controls), then it should be straight forward to move to Internet Controls for Edge.

How to get data from a website that can only be viewed in chrome

I'm trying to automate a way to pull data from a website but that website only allows me to view in chrome, firefox, safari, or opera.
I added the url into excel to power query but I'm not able to get the data I'm looking for as I get this error message below.
Any suggestions or recommendations are highly appreciated.
web address wont work with ie
You can use Selenium Basic. It will require the end user to have that framework installed, but works like a charm when Internet Explorer and MSXML aren't an option (if MSXML works, that would be preferable as it is the fastest way to retrieve data - you can find examples and explanations here as recommended by QHarr).
Note: you'll also have to update the driver that originally comes with the framework installation (you can get the latest driver for chrome here and the file to be replaced can be found in the root folder of Selenium Basic's installation C:\Users\%UserProfile%\AppData\Local\SeleniumBasic).
You'll have to select the appropriate reference within the VBA IDE: "Selenium Type Driver" and then the code goes like this:
Public Sub SeleniumImplementation()
Dim driver As New Selenium.WebDriver ' in older versions was SeleniumWrapper.WebDriver
'Late binding would be:
'Dim driver As Object
'Set driver = CreateObject("Selenium.WebDriver")
driver.start "chrome", "http://news.yahoo.com"
driver.open "/politics"
driver.stop
End Sub
You should be able to get the rest of the syntax from the autocomplete and object browser and you can take a look at more code examples here.
If Chrome is too slow, you can try PhantomJS which comes with Selenium's installation.
(Note: the code is untested.)
If you've already tried on internet explorer and it didn't work I would suggest trying the following function
dim ie as internetexplorermedium
It helps if you have securities on internet explorer. It will make your life much easier if you can use that instead.

data extraction from google chrome

I want to get table data from money control website. http://www.moneycontrol.com/financials/infosys/results/consolidated-quarterly-results/IT. I want to use google chrome to open this link and then click on previous years link and get that table too along with the table on that page. I need to click previous years as the url even after clicking previous years remains the same and I cannot directly navigate to it. It is easy with internet explorer but I cannot use it. If there is any other method other than having to click on the link please tell.
Without using a third party library it is only possible to use the Internet Explorer object.
To automate Google Chrome you can try to use Selenium VBA. It's a COM library which creates a Windows COM wrapper for Selenium.
http://florentbr.github.io/SeleniumBasic/
In Google Chrome you have to install a plugin, which helps executing the VBA commands in Chrome.
Download page: http://www.seleniumhq.org/download/

Resources