CSVで読み込んだ結果をパワーポイントに図形として挿入する

こういうCSVを読み込ませて

こういうパワーポイントにするよ
(もちろん四角は独立して動かせるよ)

Sub Sample2()
'http://officetanaka.net/excel/vba/file/file10.htm
'https://ateitexe.com/excel-vba-csv-to-multi-dimensional-array/
Dim p As String: p = ActivePresentation.Path & "\"
Dim buf As String, Target As String, i As Long, ary() As String
Dim tmp1 As Variant, tmp2 As Variant, j As Long
Target = p & "20230913_test.csv"
With CreateObject("ADODB.Stream")
.Charset = "UTF-8"
.Open
.LoadFromFile Target
buf = .ReadText
.Close
tmp1 = Split(buf, vbCrLf)
ReDim ary(UBound(tmp1) - 1, 1)
For i = 0 To UBound(tmp1)
tmp2 = Split(tmp1(i), ",")
For j = 0 To UBound(tmp2)
ary(i, j) = tmp2(j)
Next
Next i
End With
Dim sld As Slide, shp As Shape
Dim l As Single, t As Single, w As Single, h As Single
Set sld = ActivePresentation.Slides(1)
w = 10 * 8
h = 3 * 8
For i = 1 To UBound(tmp1) - 1
Set shp = sld.Shapes.AddShape(msoShapeRectangle, l, t, w, h)
shp.ShapeStyle = 1
shp.TextFrame.TextRange.Text = ary(i, 0) & vbCrLf & ary(i, 1)
shp.TextFrame.TextRange.Font.Size = 8
t = t + h
Next
End Sub

どのくらい面白かった?

星を押して送信してね

平均 0 / 5. Vote count: 0

是非フォローしてください

最新の情報をお伝えします

コメントする

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