Results 1 to 3 of 3

Thread: Help with a macro please-runs fine on one pc but not another
Thanks Thanks: 0 Likes Likes: 0

  1. #1
    Board Regular
    Join Date
    Feb 2019
    Posts
    138
    Post Thanks / Like
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

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

    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
            Do Until .readyState = 4: DoEvents: Loop
        End With
    
    
        IE.ExecWB 17, 0 '// SelectAll
        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

  2. #2
    MrExcel MVP
    Join Date
    Mar 2004
    Location
    Canada
    Posts
    18,855
    Post Thanks / Like
    Mentioned
    35 Post(s)
    Tagged
    5 Thread(s)

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

    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 by Domenic; May 20th, 2019 at 06:49 PM.

  3. #3
    Board Regular
    Join Date
    Feb 2019
    Posts
    138
    Post Thanks / Like
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

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

    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!

Some videos you may like

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •