重要なお知らせ

「教えて! goo」は2025年9月17日(水)をもちまして、サービスを終了いたします。詳細はこちら>

電子書籍の厳選無料作品が豊富!

パワポのvbaでワードに反応してメールを送るvbaを作ったのですが自由に添付ファイルをつけれるようにしたいです
どうしたらいいでしょうか?
Sub ファイル自由参照()
Const olMailItem = 0
Dim file As String
Dim pr As Presentation
Dim sl As Slide
Dim sh As Shape
Dim tb As Table
Dim r As Integer
Dim c As Integer
Dim s As String
Dim f1 As Boolean
Dim f2 As Boolean
Dim ol As Object
Dim mail As Object
With Application.FileDialog(msoFileDialogOpen)
.Filters.Add "ppt", "*.ppt?"
.InitialFileName = "ファイル名"
.AllowMultiSelect = False
If Not .Show Then Exit Sub
file = .SelectedItems(1)
End With
Do
Set pr = Presentations.Open(file)
For Each sl In pr.Slides
f1 = False
f2 = False
For Each sh In sl.Shapes
If sh.HasTable Then
Set tb = sh.Table
For r = 1 To tb.Rows.Count
For c = 1 To tb.Rows(r).Cells.Count
s = tb.Rows(r).Cells(c).Shape.TextFrame2.TextRange.Text
If InStr(s, "フレッツ") Then f1 = True
If InStr(s, "秋田") Then
If r <> tb.Rows.Count Then
If IsNumeric(tb.Rows(r + 1).Cells(c).Shape.TextFrame2.TextRange.Text) Then f2 = True
End If
End If
If f1 And f2 Then Exit Do
Next
Next
End If
Next
Next
MsgBox "無かった"
Loop Until True
pr.Close
If Not (f1 And f2) Then Exit Sub
MsgBox "見つけた" 'メール送信
Set ol = CreateObject("Outlook.Application")
Set mail = ol.CreateItem(olMailItem)
mail.Display
mail.To = "メアド" '宛先
mail.Subject = "件名"
mail.Body = "本文"
mail.Send '送信
ol.Quit
End Sub

A 回答 (1件)

こんにちは



こんな感じでは?
https://docs.microsoft.com/ja-jp/office/vba/api/ …


ご質問には関係ありませんけれど
Do
 Set pr = Presentations.Open(file)
   ~~
Loop Until True
 pr.Close
って、おかしくありませんか?
(そういうケースはないのかな?‥であれば、また違う記述になりそう。)
    • good
    • 0

お探しのQ&Aが見つからない時は、教えて!gooで質問しましょう!