1
'get the table based on the table’s id
Set ieDoc = ieApp.Document
Set ieTable = ieDoc.all.Item("contentBody")

'copy the tables html to the clipboard and paste to teh sheet
If Not ieTable Is Nothing Then
    Set clip = New DataObject
    clip.SetText "<table>" & ieTable.innerHTML & "</table>"
    clip.PutInClipboard
    Sheet1.Select
    Sheet1.Range("A1").Select
    Sheet1.PasteSpecial "Unicode Text"
End If

上記のコードを試してみたところ、もっと良い方法があることがわかりました。「contentBody」には以下が含まれます。

<div id="contentBody">
<div id="breadcrumb_navigation">
<ul class="nav nav-pills" style="margin-bottom: 0px;">
<h2 class="leftShim">Base Statistics</h2>
<div style="margin: 0px 15px 15px;">
<table class="table table-striped">
</div>
<br/>
<br/>
</div>

私がこれから欲しいのはテーブルだけです<table class="table table-stripe">

しかし、知識が不足しているため、余分な部分をどこから削除するか、または別のアプローチを試す必要があるかどうかがわかりません.

この例では、Web サイトのナビゲーション、検索、ブレッドクラムがワークシートに取り込まれます。HTML タグを使用する前にデータを取得しましたが、テーブル全体ではなくデータの断片のみであり、現在は肩をすくめてここに残されています。

4

1 に答える 1