Excel VBA中的HTML页面标题

给定一个url,我怎样才能得到在Excel中的VBA的HTML页面的标题?

例如,假设我有三个url:

  • http://url1.com/somepage.html
  • http://url2.com/page.html
  • http://url3.com/page.html

现在我需要在另一列中获得这些html页面的标题。 我该怎么做?

我不确定你的称号是什么意思,但这是一个想法:

Dim wb As Object Dim doc As Object Dim sURL As String Set wb = CreateObject("InternetExplorer.Application") sURL = "http://lessthandot.com" wb.Navigate sURL While wb.Busy DoEvents Wend ''HTML Document Set doc = wb.document ''Title Debug.Print doc.Title Set wb = Nothing 

Remou的回答对我很有帮助,但是它引起了一个问题:它不能closuresInternet Explorer进程,因为我需要运行几十次,结果打开了太多的IE,而且我的电脑无法处理这个。

所以只需添加

 wb.Quit 

一切都会好起来的

这是适合我的代码:

 Function GetTitleFromURL(sURL As String) Dim wb As Object Dim doc As Object Set wb = CreateObject("InternetExplorer.Application") wb.Navigate sURL While wb.Busy DoEvents Wend GetTitleFromURL = wb.Document.Title wb.Quit Set wb = Nothing End Function