0

I have code to pull general data from a website into excel using a macro, e.g. yahoo finance quotes. But, is it a possibility to pull data from a secure website (one that requires login) to automate a report? The link provided was close, but I dont understand how to pass the parameters in. Also, when I run this I only get a dialog box with an "X" and nothing else... An edit: I am pulling from SAP SuccessFactors. I can get the macro to pull a pdf, associated with a URL, but it wont grab an ad hoc excel report. If anyone has any ideas that would be great! I have pasted my code below:

Dim driver As New Selenium.WebDriver
Public Sub DownloadFile()
    driver.Start "Chrome"
    driver.Get "https://performancemanager4.successfactors.com/login company=Arrow&username=A79123"
    driver.Wait 20000
    driver.Get "https://performancemanager4.successfactors.com/acme?fbacme_n=analytics&bplte_company=Arrow&_s.crb=EAYY%2bFNmT7%2b%2b8%2fbKt4IEV6RmGRM%3d"
    driver.Wait 1000
    driver.Get "https://performancemanager4.successfactors.com/acme?_s.crb=EAYY%252bFNmT7%252b%252b8%252fbKt4IEV6RmGRM%253d#focus"
    driver.Wait 1000
    driver.Get "file:///C:/Users/a79123/Downloads/report_Hires_by_Job_Family_Sarah_07a6559d-98a8-436d-b686-5abd2a2c631d.pdf"
End Sub
Community
  • 1
  • 1
Natester 13
  • 15
  • 1
  • 3
  • Possible duplicate of [How do i download a file using VBA (Without internet explorer)](http://stackoverflow.com/questions/17877389/how-do-i-download-a-file-using-vba-without-internet-explorer) – Bruce P Nov 03 '15 at 19:03

2 Answers2

0

The following link shows a way to download data from the web, allowing you to pass a username and password: https://stackoverflow.com/a/17877390/5521518

Community
  • 1
  • 1
BakersCat
  • 33
  • 7
0

I had been playing around with Selenium a bit in VBA a few months back. The best way I found was to put a wait time in the code that gives you ample time to log in to the site and then let the code take it from there once in. I think the biggest issue I ran in to was not storing a username and password in the code should someone else want to use it or creating a form with hidden text for the password field was difficult with Excel.

Dim driver As New SeleniumWrapper.WebDriver
Public Sub getData()
   driver.Start "IE"
   driver.Open "your site here"
   driver.Wait 20000 ' use this time to log in
   ' more code here
End Sub
  • It would be a good idea to have the machine wait, but when I try the Dim driver As New SeleniumWrapper... I get an error that says user defined object not defined? – Natester 13 Nov 03 '15 at 22:36
  • You'll have to install it first to be able to use it. You should be able to grab it here http://florentbr.github.io/SeleniumBasic/ –  Nov 03 '15 at 23:51
  • I got the Selenium tool, it is certainly very cool. Do you put the code above into the VBA code within Excel? I am doing that but it still isnt correct. – Natester 13 Nov 10 '15 at 20:35
  • I would double check and make sure you add it as a reference under tools--> references--> seleniumwrapper tpe library. To test it out put whatever link you are using after the driver.open and it should open Internet explorer to your webpage then wait. From there you'll have to experiment a bit with the selenium library for the rest but there are a lot of commands in it for interacting with webpages. I think as long as your not dealing with iframes it shouldn't be too bad. Selenium should have come with some sample code that should help you get going as well. Just check in the installed files. –  Nov 11 '15 at 18:50
  • Ah! That did it! Do you know if there is a way to capture my actions on the web and have this run that script in order to locate and export a report in xls? I can get it to grab and download the report in a pdf, but xls is harder because it doesnt come with a url... This is so cool though! – Natester 13 Nov 13 '15 at 21:07
  • It does have a plugin for Firefox that can record your actions as you navigate pages. That might help you as well with your situation. https://addons.mozilla.org/en-US/firefox/addon/selenium-ide-button/ –  Nov 14 '15 at 14:28
  • yeah, I have been fiddling with that as well. Just trying to figure out how to utilize it to access this report. Because it opens up a couple of different frames the recording gets stuck and an error appears... – Natester 13 Nov 16 '15 at 16:32