Forum

VBA to send data fr...
 
Notifications
Clear all

VBA to send data from excel spreadsheet to a website form and return result to spreadsheet

9 Posts
2 Users
0 Reactions
158 Views
(@dave_mac_24)
Posts: 7
Active Member
Topic starter
 

Hi all

Can anyone please help with providing code that would allow me to:

1. Send each of the numbers in column A of the attached spreadsheet (and indeed any amount of numbers included in column A) ie:-

238554836
166913834
205963701
343475355
220430231

to http://ec.europa.eu/taxation_customs/vies/

2. Select GB-United Kingdom on the top down menu

3. Enter each of the numbers in turn into the VAT number box below the above drop down

4. Return the name of the relevant business back to the spreadsheet in column B next to the original VAT number

Any help would be much appreciated?

Thanks
Dave

 
Posted : 30/04/2019 11:33 am
Philip Treacy
(@philipt)
Posts: 1629
Member Admin
 

Hi Dave,

I think I can do this but it will take some time to code + test.

I'll try to get back to you tomorrow.

Regards

Phil

 
Posted : 01/05/2019 6:59 pm
(@dave_mac_24)
Posts: 7
Active Member
Topic starter
 

Hi Phil

If you can figure it out you will be an absolute legend!

Thanks

Dave

 
Posted : 02/05/2019 4:28 am
(@dave_mac_24)
Posts: 7
Active Member
Topic starter
 

Hi Phil

Any joy with this - I'm guessing it's proved harder than you first thought? 🙂

Thanks

Dave

 
Posted : 08/05/2019 10:01 am
Philip Treacy
(@philipt)
Posts: 1629
Member Admin
 

Sorry Dave, I am having intermittent success with the code.

The problem I'm having is that once the results page is loaded and I tell the VBA to grab the HTML page contents, it returns the first page where you enter the VAT number. 

Sometimes it gets the correct page, but most of the time it does not.  I can't figure out why.

I'm going to try a different approach and see if I have success with that.

Cheers

Phil

 
Posted : 15/05/2019 3:17 am
(@dave_mac_24)
Posts: 7
Active Member
Topic starter
 

Hi Phil

Thanks for the update. The worst kind of coding issues for me are when it sometimes returns the right result - I would rather it didn't work at all than did that as it makes it so frustrating. I really appreciate your efforts - good luck with the different approach!

Thanks

Dave

 
Posted : 16/05/2019 3:19 am
Philip Treacy
(@philipt)
Posts: 1629
Member Admin
 

Hi Dave,

Sorry for the long delay.  This was partly due to other commitments but partly due to getting this to work.  I gave up on using IE.

The attached workbook contains code that will do as you want.  It requires installation of the SeleniumBasic VBA wrapper https://github.com/florentbr/SeleniumBasic/releases and you will need to download and install the latest Chrome driver https://sites.google.com/a/chromium.org/chromedriver/

Copy the Chrome driver to the Selenium installation folder which on my PC is C:UserspgtAppDataLocalSeleniumBasic.  This will copy over the driver that came with the SeleniumBasic install.

Selenium is software that allows you to automate a browser.  I used Chrome, and the Chrome driver is the software link between Selenium and the Chrome browser.  So you will need to install Chrome if you haven't got it already.

The code will loop through a list of numbers in Col A until it reaches the last one.

I'm about to write a blog post to elaborate on the process behind all of this.

Regards

Phil

 
Posted : 29/05/2019 1:13 am
(@dave_mac_24)
Posts: 7
Active Member
Topic starter
 

Thanks Phil - that works perfectly 🙂 The code is pretty simple once you know how to actually do it, but I'd never have figured that out myself, so really appreciate your help. Please could you let me know when your blog post is up, as I would be interested to have a read?

 
Posted : 29/05/2019 10:44 am
Philip Treacy
(@philipt)
Posts: 1629
Member Admin
 

Hi Dave,

Here's the post

https://www.myonlinetraininghub.com/web-scraping-filling-forms

Regards

Phil

 
Posted : 31/05/2019 6:46 am
Share: