Dealing with Error 462 in Excel VBA When Using Internet Explorer

This function is designed to loop through the hrefs obtained from the GetData() function, navigate each page, retrieve specific data, and then move on to the next one.

Sub CreateDatabase()
    Dim ieNewPage As InternetExplorer, TableRows As Object, TableRow As Object
    Dim TableRowsSpecificOwner As Object, TableRowSpecificOwner As Object, TagNeeded As Object
    Set TableRows = GetData()
    Set ieNewPage = New InternetExplorer
    For Each TableRow In TableRows
        ieNewPage.navigate CStr(TableRow.href)
        Do While ieNewPage.ReadyState <> 4
            DoEvents
        Loop
        ieNewPage.Visible = True
        Set TableRowsSpecificOwner = ieNewPage.document.querySelectorAll("tr[class='puce_texte']")
        For Each TableRowSpecificOwner In TableRowsSpecificOwner
            If Excel.Application.IfError(Excel.Application.Search("France", TableRowSpecificOwner.innerText), -1) > 0 Then
                    Debug.Print TableRow.innerText
                    Debug.Print TableRowSpecificOwner.getElementsByTagName("a")(1).innerText
            End If
        Next
        Excel.Application.Wait (Now + TimeValue("0:00:02"))
    Next
End Sub

However, after successfully processing the first link, I encounter an error message 462:

The remote server does not exists or is unavailable.

This error occurs at the following line:

ieNewPage.navigate CStr(TableRow.href)

I am unsure how to resolve this issue? Any suggestions?

Answer №1

If you're encountering an issue with Excel automation failing when running the code a second time, there is a helpful article addressing this specific error titled Excel automation fails second time code runs that you might find useful to review. The root cause of this problem is:

The error stems from Visual Basic creating a reference to Excel due to unqualified calls to Excel objects, methods, or properties in the code. This reference persists until the program ends, causing interference with subsequent automation code executions.

One potential solution could be ensuring that you use the Set for ieNewPage each time it's called within the loop. You may want to consider inserting

Set ieNewPage = New InternetExplorer
inside the loop structure as shown below:

...    
Set TableRows = GetData()    
For Each TableRow In TableRows
    Set ieNewPage = New InternetExplorer
    ieNewPage.navigate CStr(TableRow.href)
    ...
Next
...

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Create a webpage in full screen mode with a video player that fills the entire screen

Here is the HTML code I am working with: <div id="container"> <video id="video" src="video.ogv" loop></video> </div> The "container" div and video element occupy the entire screen. #container { po ...

The event listener for jQuery's document.ready doesn't trigger, rendering all jQuery functions ineffective

After researching similar issues on various forums, I have attempted the following troubleshooting steps: replacing all $ with jQuery ensuring the correct src is used implementing jQuery.noConflict() My goal is to retrieve data from a SQLite3 database w ...

Enhancing user experience with CSS dropdown menu animations

I've been working on adding a dropdown transition to my menu, but I can't seem to get it right. Can anyone point out where I'm going wrong or what needs to be added for the transition effect on the dropdown menu? Here is the CSS and HTML cod ...

Browsing through dual snap points simultaneously on Google Chrome

I'm currently developing a website that incorporates scroll snapping for 3 viewport-sized <section> elements set up like so: html, body { scroll-behavior: smooth; scroll-snap-type: mandatory; scroll-snap-points-y: repeat(100vh); scrol ...

Controlling the back DIV while maintaining overlapping layers

I successfully positioned my right hand content on top of the leaflet map in the background using CSS properties like position and z-index. However, I am looking for a way to make the overlapping div not only transparent but also non-interactive while stil ...

The issue of JQuery recursion not properly focusing on a textbox

Can anyone help with a jquery focus issue I'm experiencing? My goal is to address the placeholder problem in IE by focusing on an element and then blurring it to display the placeholder. This functionality is being used in a modal form. Initially, e ...

Is there a more efficient method for replacing all attributes on cloned elements?

While this code does the job, I can't help but feel like it's a bit outdated. I'm not very experienced with JS/JQuery and only use them when necessary. My approach involves cloning an element and then replacing all of its attributes with on ...

Ways to incorporate the setTimeOut function

<body> <script> $(window).scroll(function() { $('#csgo').each(function(){ var imagePos = $(this).offset().top; var topOfWindow = $(window).scroll ...

Adjust the height of a div according to the width using CSS in a progressive manner

I'm looking to create a fluid container that adjusts its height gradually based on the width of the window (as the div's width is set to 100%). Similar to the behavior achieved with the aspect-ratio CSS rule, I want the height to smoothly increas ...

Obtaining table data and HTML elements using the correct code - Selenium and Python

I've been attempting to extract the ticker symbol, stock name, price, sector, and market cap columns from this website. I'm facing challenges in identifying the correct HTML elements using the appropriate code. Although I've used Selector Ga ...

Click on the hyperlink to adjust the background size of an inline list item

I created a navigation bar using inline display for the li elements. I want my last column to have a defined height background. However, it is only displaying a background behind the name of the column. Here is the relevant section from style.css: #navi ...

Retrieve the outer-HTML of an element when it is clicked

I am working on a project to develop a tool for locating xpath, and I am seeking the most efficient and user-friendly method for allowing the user to select the desired element on a webpage. Ideally, this selection should be made with just a single click, ...

Turn off the CSS hover effect for a custom button if the ng disabled attribute is set to true

My goal is to disable custom buttons, and the disable(pointer) function is working correctly. The issue arises when we try to hover on the button, as the hover effect still works. I therefore need to disable hover as well. I am looking to apply ng-disabl ...

How can you make a Dropdown Box with Javascript?

My current table setup is as follows: <table> <tbody> <tr> <td>List 1</td> <td>List 2</td> <td>List 3</td> <td>....</td> </tr> <tr> <td>This section would be the dropdown ...

What could be causing the audio to not function properly on the webpage I'm working on that has yet to be launched?

As I work on my webpage, I am attempting to incorporate an audio file from SoundCloud. However, it seems that the file is not playing when sourced directly from the SoundCloud website. It works fine when the source is a file stored on my computer. <aud ...

Show the cell data when the checkbox next to it is selected

I have a specific table setup and I am trying to display the content of the table cell if its corresponding checkbox is checked upon clicking a button. For example: If Row2 is checked, an alert box should display Row2 Below is my code snippet, Java ...

Unleashing the power of specific dates with the angularJS datepicker directive

I am looking to develop a custom Datepicker directive using Angular JS, with the requirement of allowing only specific dates for selection by the user. For instance, I have a predefined list of numbers such as 1,3,5,7, and my goal is to make these particu ...

Utilizing Rvest for extracting data from LinkedIn profiles

I've been trying to scrape my LinkedIn profile using Rvest, but I encountered a problem in the experience section. The XPath below was supposed to retrieve the experience section, but it's returning 0 nodes: Test <- read %>% html_nodes(xpath = & ...

Is it better to store CSS and JavaScript in separate files or within the main HTML document

While the best practice is to place JavaScript and CSS code in separate files (such as .js and .css), many popular websites like Amazon, Facebook, etc. often include a large portion of their JavaScript and CSS code directly within the main HTML page. Whic ...

Extracting information from various tables when exporting in Laravel

I currently have two tables on hand: Accessory Request Table Accessory Details Table It's worth noting that one accessory request can have multiple entries in the accessory details table. However, when I attempt to export the data, only information ...