Help with a macro please-runs fine on one pc but not another

Buns1976

Board Regular
Joined
Feb 11, 2019
Messages
194
Office Version
  1. 365
Platform
  1. Windows
Hi Everyone,

I am running a macro that in a nutshell Opens Internet Explorer, does Select All and Copy, and then pastes to
cell A1 in a worksheet. It works flawlessly on one PC but hangs up on the Orange highlighted line below on another
PC. Both PC's are running Windows 10 with exactly the same versions of Excel and Internet Explorer!

Any help would be greatly appreciated!

Code:
Sub IMPORT_HTML()    Application.ScreenUpdating = False
Application.ExecuteExcel4Macro "show.toolbar(""Ribbon"",True)"


 Dim IE As Object
    Sheets("IMPORT_HTML").Visible = True
    'ActiveWindow.DisplayWorkbookTabs = True
    Sheets("IMPORT_HTML").Select
    Sheets("IMPORT_HTML").Cells.Select
    Sheets("IMPORT_HTML").Select
    With Selection
        .WrapText = False
        .Orientation = 0
        .AddIndent = False
        .IndentLevel = 0
        .ShrinkToFit = False
        .ReadingOrder = xlContext
        .MergeCells = False


    End With
    Range("A1:Q1000") = "" ' erase previous data
    Range("A1").Select
    Shell ("C:\Back Office\CLEAR_CLIPBOARD.BAT")
    Set IE = CreateObject("InternetExplorer.Application")
    With IE
        .Visible = False
        .navigate "file:///C:/Users/dmgpe/Dropbox/DAILY_SALES_REPORTS/DAY_END.HTML" ' should work for any URL
[B][COLOR=#ff8c00]        Do Until .readyState = 4: DoEvents: Loop[/COLOR][/B]
    End With


    IE.ExecWB 17, 0 '// SelectAll[COLOR=#0000cd][/COLOR]
    IE.ExecWB 12, 2 '// Copy selection
    Sheets("IMPORT_HTML").Select
    Range("A1").Select
    Sheets("IMPORT_HTML").PasteSpecial Format:="HTML", link:=False, DisplayAsIcon:=False
    Sheets("DASHBOARD").Select
    Range("H3").Select
    Sheets("IMPORT_HTML").Visible = False
    IE.Quit
    'IE.Quit ' just to make sure
    Application.DisplayFullScreen = True
    Application.ExecuteExcel4Macro "show.toolbar(""Ribbon"",False)"
    Application.ScreenUpdating = True
   
End Sub
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
Try checking the Busy property as well...

Code:
    Do While .Busy Or .readyState <> 4 'READYSTATE_COMPLETE
        DoEvents
    Loop

If you're still having problems, you can try pausing the macro for a few seconds as well after the Do While/Loop.
 
Last edited:
Upvote 0
Hi Domenic,

I just figured it out. IE was running in the background. I put a line of code in the beginning of the macro
to make sure it is completely closed.

Thanks for the help!
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,289
Members
452,631
Latest member
a_potato

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