UK License Plate Searcher

Hgreen1601

New Member
Joined
Jun 15, 2021
Messages
18
Office Version
  1. 2016
Platform
  1. Windows
I have been trying to make a macro where I enter a license plate and it searches the gov.uk website (https://vehicleenquiry.service.gov.uk) and returns the cylinder capacity.

Relatively new to macro writing so any explanation would be appreciated, currently have numerous errors.

VBA Code:
Sub EngineSearch()

    Dim Tool      As Object
    Dim Var     As Variant
    Dim element As Variant
    Dim WrkBk   As Workbook
    Dim WrkSht  As Worksheet
   
    Set WrkBk = ThisWorkbook
    Set WrkSht = WrkBk.ActiveSheet

    For i = WrkSht.Range("E3").Value To WrkSht.Range("F3").Value
    'Have put the cells of my data range within these values
   
   
    Set Tool = CreateObject("InternetExplorer.Application")
    Tool.navigate "[URL]https://vehicleenquiry.service.gov.uk/[/URL]"

    Tool.Visible = False
   
    Application.Wait (Now + TimeValue("0:00:01"))

    Set frm = Tool.document.getelementbyid("wizard_vehicle_enquiry_capture_vrn_vrn")

    frm.Value = WrkSht.Cells(i, 2).Value
       
    Tool.document.getelementbyid("submit_vrn_button").Click
   
    Application.Wait (Now + TimeValue("0:00:01"))

    Tool.document.getelementbyid("yes-vehicle-confirm").Click
    Tool.document.getelementbyid("capture_confirm_button").Click
   
    Application.Wait (Now + TimeValue("0:00:01"))

    Set HtmlType = ie.document.getelementbyid("cylinder_capacity")
    WrkSht.Range("C" & i) = Right(HtmlType.innerText, 7)
  

    Tool.Quit


    Next i
   
Exit Sub
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
For 'DIESEL' it's the same way as for 'cc' : Cells(R, 5).Value2 = .Document.querySelector("#fuel_type>dd").innerText …​
 
Upvote 0
I'm getting a lot of "not found", generally when it occurs once it continues to happen. Are there any changes I could make it improve it's success rate? Although it does fix itself sometimes.
 
Upvote 0
I tried with the sample plate 'CU57ABC' - to have a 'not found' return - inserted between valid plates : no issue on my side …​
So I suspect it's a web issue on your side : synchronization issue / slow connection, website watching your IE process, …​
 
Upvote 0
I tried with the sample plate 'CU57ABC' - to have a 'not found' return - inserted between valid plates : no issue on my side …​
So I suspect it's a web issue on your side : synchronization issue / slow connection, website watching your IE process, …​
Yes I suspect it is to do with poor internet connection. Is it possible to add a time delay to allow for each search to allow for this?
 
Upvote 0
Thanks to not quote each time the complete previous post as that's just clutter …​
You must already have seen there is already a time delay in my VBA procedure ! Just increase it …​
 
Upvote 0
Will do!

Oh great, didn't know if it needed one later in the module - thanks!
 
Upvote 0
But taking a glance on my procedure the '¤ not found' message seems to not need any time delay as the procedure waits until the webpage is 'complete' …​
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,335
Members
452,636
Latest member
laura12345

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top