Using TAB CLOSE in VBA opens URL in wrong browser

Discussions and Tech Support related to automating the iMacros Browser or Internet Explorer from any scripting and programming language, such as VBS (WSH), VBA, VB, Perl, Delphi, C# or C++.

Moderators: Community Moderators, iMacros Moderators

Forum rules
Before asking a question or reporting an issue:
1. Please review the list of FAQ's.
2. Use the Google search box (at the top of each forum page) to see if a similar problem or question has already been addressed. This will search the entire contents of the forums as well as the iMacros Wiki.
3. We can respond much faster to your posts if you include the following information:


Answering your own posts (e.g. attempting to "bump" your topic) drops your topic from the list of unanswered threads, so it may actually receive less views.

Using TAB CLOSE in VBA opens URL in wrong browser

by Ske on Mon Apr 13, 2015 2:49 pm

Can't figure this one out, in fact it's hard to explain the issue.

This is a simplified version of my code that causes this issue, for easier reproduction:
Code: Select all
Private Sub UndueBrowserOpenTestClean()

    Set iim1 = CreateObject("imacros")
    iret = iim1.iimInit

    For rowHtm = 2 To 100

        strURL = ""

        macro = ""
        macro = "TAB OPEN" + vbNewLine
        macro = macro + "TAB CLOSE" + vbNewLine
        'macro = macro + "WAIT SECONDS=1" + vbNewLine
        macro = macro + "SET !TIMEOUT_PAGE 30" + vbNewLine
        macro = macro + "URL GOTO=" & strURL & "" + vbNewLine
        'macro = macro + "WAIT SECONDS=1" + vbNewLine

        macro = macro + "SET !TIMEOUT_STEP 1" + vbNewLine
        macro = macro + "TAG POS=1 TYPE=DIV ATTR=ID:breadcrumbNavigation EXTRACT=TXT" + vbNewLine

        Status = iim1.iimPlayCode(macro)

        strBreadcrumb = iim1.iimGetLastExtract(1)
        If strBreadcrumb = "#EANF#" Then
            macro = "WAIT SECONDS=1" + vbNewLine
            GoTo RetryExtraction
        End If
    Next rowHtm

End Sub

The code uses the Imacros browser (v10) and runs fine, but every once in a while the URL opens both in the Imacros and the default browser (IE or chrome on different computers). In the default browser nothing happens with it, only an additional tab gets opened, but that means that after some time I have 50+ tabs open in the default browser, so eventually something crashed.

I've already experimented quite a bit with it, the issue happens in
  • Win 8, Win 7, Win Vista
  • Excel 2013 and 2010 (both 32 bit)
  • with different extracts
  • with default browsers
  • running the imacros code in different steps, eg separately close tabs, open URL, extract data in individual macros
  • adding WAIT SECONDS lines

What does prevent the issue is avoiding any TAB CLOSE lines in the code. (The reason I don't want to do that is that in my real code I loop through different ProductID= numbers, and sometimes the extract contains the results from the previous URL, apparently because the extraction is made before the new URL is fully done loading)

Another symptom: while the URL in the address bar of the Imacros browser lists correctly as e.g:
in the default browser it appears as either:

Posts: 6
Joined: Wed Jan 13, 2010 4:45 am

Return to Scripting and Command Line Interface

Who is online

Users browsing this forum: Majestic-12 [Bot] and 5 guests