Results 1 to 2 of 2

I need this code to work on a Macbook

Threaded View

cabroncito29 I need this code to work on a... 02-10-2016, 08:54 AM
Kyle123 Re: I need this code to work... 02-10-2016, 10:32 AM
  1. #1
    Registered User
    Join Date
    10-08-2012
    Location
    Cedar Falls, Iowa
    MS-Off Ver
    Excel 2007
    Posts
    50

    I need this code to work on a Macbook

    The following code works fine on a PC-based computer. Can someone help me tweak it so it will work on a MacBook running Excel?

    Sub XMLHTTP()
    
        Dim url As String, lastRow As Long
        Dim XMLHTTP As Object, html As Object, objResultDiv As Object, objH3 As Object, link As Object
        Dim start_time As Date
        Dim end_time As Date
    
        lastRow = Range("A" & Rows.Count).End(xlUp).Row
        
        Dim cookie As String
        Dim result_cookie As String
        
        start_time = Time
        Debug.Print "start_time:" & start_time
        Dim Test As Object
        
    
        For i = 2 To lastRow
    
            'url = "https://scholar.google.com/scholar?hl=en&q=" & Cells(i, 1) & "&rnd=" & WorksheetFunction.RandBetween(1, 10000)
            url = "http://www.ncbi.nlm.nih.gov/pubmed/?term=" & Cells(i, 1) ' & "&rnd=" & WorksheetFunction.RandBetween(1, 10000)
    
            Set XMLHTTP = CreateObject("MSXML2.serverXMLHTTP")
            XMLHTTP.Open "GET", Trim(url), False
            'XMLHTTP.setRequestHeader "Content-Type", "text/xml"
            XMLHTTP.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
            XMLHTTP.setRequestHeader "User-Agent", "Mozilla/5.0 (Windows NT 6.1; rv:25.0) Gecko/20100101 Firefox/25.0"
            XMLHTTP.send
    
            Set html = CreateObject("htmlfile")
            html.body.innerHTML = XMLHTTP.ResponseText
    '       Cells(i, 3) = html.body.innerHTML
          
            Set objResultDiv = html.getelementbyid("see_pmcommons")
            If objResultDiv Is Nothing Then
                GoTo NextLoop
            Else
            Cells(i, 2) = "= Hyperlink(""" & url & """)"
    '            Cells(i, 2) = url
            End If
    '        Set objH3 = objResultDiv.getelementsbytagname("H3")(0)
    '        If objH3 Is Nothing Then
    '            GoTo NextLoop
    '        Else
    '            Set link = objH3.getelementsbytagname("a")(0)
    '        End If
    
    
    '        If link Is Nothing Then
    '        Else
    '            Cells(i, 2) = link.href
    '        End If
    NextLoop:
            DoEvents
        Next
        
        end_time = Time
        MsgBox "Done"
        
    End Sub
    Attached Files Attached Files

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Excel Form not working on Macbook
    By lorber123 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-24-2016, 02:38 PM
  2. Replies: 1
    Last Post: 11-07-2015, 10:50 AM
  3. macbook - missing toolbar for vba, where can I find it?
    By wfykitty in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-13-2015, 02:24 PM
  4. Macro For Pivot Table in Macbook Excel 2011
    By Mkapil in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-20-2015, 01:48 AM
  5. Replies: 1
    Last Post: 06-12-2014, 05:13 AM
  6. Excel 2008 : excel 2008 problems: macbook pro
    By mg9175 in forum Excel General
    Replies: 1
    Last Post: 01-16-2011, 12:15 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