PubmedAPIを利用して文献IDからAbstractやTitleを読み込むFunction
Sub Pubmed2()
Dim arr As Variant, PubmedID As Long
PubmedID = 2644239
arr = GetTitle(PubmedID)
MsgBox " Abstract " & arr(1)
MsgBox " Title " & arr(2)
End Sub
Function GetTitle(PMID As Long) As String()
On Error GoTo Err
Dim xmlNode(2) As String
ReDim tempgettitle(2) As String
Dim xdoc As MSXML2.DOMDocument
Dim httpObj As Object
url = "https://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?db=pubmed&id=" & PMID & "&retmode=xml"
xmlNode(1) = "//PubmedArticleSet/PubmedArticle/MedlineCitation/Article/Abstract/AbstractText"
xmlNode(2) = "//PubmedArticleSet/PubmedArticle/MedlineCitation/Article/ArticleTitle"
Set httpObj = CreateObject("Microsoft.XMLHTTP")
httpObj.Open "GET", url, False
httpObj.send ("")
Set xdoc = httpObj.responseXML
For i = 1 To 2
Set xmltxt = xdoc.SelectSingleNode(xmlNode(i))
tempgettitle(i) = xmltxt.Text
Next
GetTitle = tempgettitle
Set httpObj = Nothing
Exit Function
Err:
Debug.Print "Error"
End Function