![]() SendKeys() is in the most cases a realy bad solution. If you get the downlad link you can also use API function URLDownloadToFile() instead of the click and SendKeys(). How to use excel vba to click on interactive dialog pop-up? But here you can take a look how those kind of problems can be solved with code generating pages, HTML events and (I think you will need it) SendKeys(): I don't know what kind of pop up it is on your site. MsgBox "There is no Element with the CSS class 'downloadLinkButton' in the used HTML document" 'Check whether the variable elements contains a HTML element Set elements = 圜lassName("downloadLinkButton")(0) 'Break for 5 seconds to looad more data if neededĪpplication.Wait (Now + TimeSerial(0, 0, 5)) 'Dim aEle As HTMLLinkElement 'special object variable for an (link) element You can do this with Application.Waitįourth: If the shown line generates an error, I think you don't work on the pop up html code were the link is.ĭim objIE As InternetExplorer 'special object variable representing the IE browser Third: It can be the page needed more time to load completly, because there are information which must load too. You can use Set elements = 圜lassName("downloadLinkButton")(0) to get the link directly, if its the only link with this CSS class in the document. Second: You don't need the loop to find the download link. The important part begins at įirst of all: Use always the line Option Explicit as first line in every code module! (The URLs I have in the code/HTML are obviously not the real URLs).Įdit: Below is the HTML for the button which must be clicked to expand the menu that contains the "Export to CSV" option. I'm not very familiar with how Blob URLs work, but I think that the download URL changes. If (ele.className = "downloadLinkButton") ThenĪs I mentioned, this macro doesn't error out, it just opens the browser to the webpage I want.ĭoes anyone have advice on how I could automate this download? ![]() 'make IE browser visible (False would allow IE to run in the background)ĭo While objIE.Busy = True Or objIE.ReadyState 4: DoEvents: Loop 'initiating a new instance of Internet Explorer and asigning it to objIE This is the code that I've written, but it doesn't work: Dim objIE As InternetExplorer 'special object variable representing the IE browserĭim aEle As HTMLLinkElement 'special object variable for an (link) element ![]() My code (without sensitive information) and a little code taken by 'HTTP Header Live'. When I save the bytes (I'm using a WinHTTP request), in an. I got the below HTML by using "Inspect Element" (I cut out parts that didn't seem relevant). 1 I'm trying to download a file from a protected webpage (from my job, so I cannot post the url). I haven't been able to get it to work yet: It opens the browser to the webpage I want, but it doesn't download the CSV. I wrote a macro that's supposed to open an Internet Explorer window, then click on the download button in order to download the CSV file I want to download. The user interface for the web application has you click on a button to open a menu, then click on a download button within the pop-up menu. I want to write a macro in Excel that will download a CSV from a web application I use for my job. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |