Excel VBA to get website Title from url

前端 未结 1 2011
悲哀的现实
悲哀的现实 2021-01-27 23:17

HTML Page Title in Excel VBA

I know that this is fairly old but I\'m having difficulty with this. I\'ve built a browswer history parser that goes through the history dat

相关标签:
1条回答
  • 2021-01-27 23:36

    Try this. Works fine for me in MS Excel 2010

    Dim title As String
    Dim objHttp As Object
    Set objHttp = CreateObject("MSXML2.ServerXMLHTTP")
    objHttp.Open "GET", "http://www.google.com/", False
    objHttp.Send ""
    
    title = objHttp.ResponseText
    
    If InStr(1, UCase(title), "<TITLE>") Then
        title = Mid(title, InStr(1, UCase(title), "<TITLE>") + Len("<TITLE>"))
        title = Mid(title, 1, InStr(1, UCase(title), "</TITLE>") - 1)
    Else
        title = ""
    End If
    
    MsgBox title
    
    0 讨论(0)
提交回复
热议问题