SeleniumBasicを使用してテーブルデータ取得【PowerPointVBA】

PowerPointVBAでSeleniumBasicを使用しGoogleChromeを自動化し、テーブルデータを取得。

そしてテーブルと同じサイズの表をスライドに挿入し、画像として出力するまでの一連の流れ。

実際に使用したサンプルコード-----------------------------------

Option Explicit
Public Sub Sample()

Dim driver As New Selenium.ChromeDriver

Dim 配列 As Variant

driver.Get "https://vba.company/samplepage/2/"

配列 = driver.FindElementByCss("#post-494 > div > div.wp-block-group.is-layout-flow.wp-block-group-is-layout-flow > div > div > div > figure > table").AsTable.Data

ActivePresentation.Slides(1).Shapes.AddTable(UBound(配列, 1), UBound(配列, 2)).Name = "sample"

Dim i As Integer
Dim x As Integer

For x = 1 To UBound(配列, 1)

For i = 1 To UBound(配列, 2)

    ActivePresentation.Slides(1).Shapes("sample").Table.Cell(x, i).Shape.TextFrame.TextRange.Text = 配列(x, i)

Next

Next

ActivePresentation.Slides(1).Export ActivePresentation.Path & "\sample.jpg", "JPG"

End Sub

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です