+ Reply to Thread
Results 1 to 20 of 20

Excel 2010 to 2016 broke VB code?

Hybrid View

  1. #1
    Valued Forum Contributor
    Join Date
    02-14-2019
    Location
    Turkiye
    MS-Off Ver
    2010 - 64 Bit on Windows-11 (24 H2) 64 Bit
    Posts
    1,185

    Re: Excel 2010 to 2016 broke VB code?

    Rick;

    I've encountered with the same error. I am using Excel 2010 (32 Bit) on Win7-Home (64 bit).

    I changed the 2nd part of the code and instead of using "WinHttp.WinHttpRequest" I used "MSXML2.XMLHTTP" object.

    Here is the revised code that works fine for me;

    Sub Test()
        'Haluk - 18/07/2019
        'sa4truss@gmail.com
        
        Dim xmlHTTPReq As Object
        Dim postURL As String
        Dim L As Long
        
        postURL = "https://www.wsj.com/market-data/bonds"
        
        With ActiveSheet.QueryTables.Add(Connection:="URL;" & postURL, Destination:=Range("$B$2"))
            .Name = "myQuery"
            .FieldNames = True
            .RowNumbers = False
            .FillAdjacentFormulas = False
            .PreserveFormatting = True
            .RefreshOnFileOpen = False
            .BackgroundQuery = True
            .RefreshStyle = xlOverwriteCells
            .SavePassword = False
            .SaveData = True
            .AdjustColumnWidth = True
            
            .RefreshPeriod = 0
            
            .WebSelectionType = xlSpecifiedTables
            .WebTables = 1
            
            .WebFormatting = xlWebFormattingNone
            .WebPreFormattedTextToColumns = True
            .WebConsecutiveDelimitersAsOne = True
            .WebSingleBlockTextImport = False
            .WebDisableDateRecognition = False
            .WebDisableRedirections = False
            .Refresh BackgroundQuery:=False
        End With
        
        Set xmlHTTPReq = CreateObject("MSXML2.XMLHTTP")
        
        With xmlHTTPReq
            .Open "GET", postURL, False
            .send
        End With
        
        L = InStr(xmlHTTPReq.responseText, "Rates shown are effective")
        If L Then ActiveSheet.Range("A12") = Mid(xmlHTTPReq.responseText, L, InStr(L, xmlHTTPReq.responseText, "</") - L)
        
        Set xmlHTTPReq = Nothing
    End Sub
    .
    Last edited by Haluk; 07-18-2019 at 01:48 PM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. file from Excel 2016 opened with 2010
    By thoandros in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 01-22-2019, 03:44 AM
  2. Excel 2010 VS 2016
    By lostsoul65 in forum Excel General
    Replies: 3
    Last Post: 05-25-2018, 09:52 AM
  3. VBA Code works in 2010, but not in 2016
    By duffynmu in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 12-05-2017, 04:11 AM
  4. 2010 Macro not working in 2016 Excel
    By porepiga in forum Excel General
    Replies: 7
    Last Post: 04-18-2017, 12:11 PM
  5. Opening Excel 2010 in 2016 causes double images
    By tlshook in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-28-2016, 12:48 PM
  6. [SOLVED] Issues with code sent from 2010 to 2016
    By dwr2 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-10-2016, 03:57 PM
  7. Replies: 2
    Last Post: 05-17-2016, 12:23 PM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1