パワーポイントを起動し、Excelデータをコピーする

パワーポイントにExcelのデータをコピーするには、テキスト用のスライド(ppLayoutText)を追加します。
テキストはシェイプオブジェクトに記入します。


Homeに戻る > Excel プログラムのTipsへ

実行画面

「Power Pointに入力」ボタンをクリックすると、C7のタイトルとC8:C9のテキストをPowerPointを起動し入力します。
PowerPointにコピーするExcel画面

PowerPointの画面です。
タイトルとテキストが入力されています。
テキストのShapeが選択状態なのが分かります。
PowerPointに入力されたテキスト文字列


実行VBAコード

Option Explicit
 
Private Sub CommandButton1_Click()
    Dim tpp As PowerPoint.Application
    Dim newtpp As Object
    
    'PowerPointのインスタンスを生成
    Set tpp = CreateObject("Powerpoint.Application")
    
    '新規にプレゼンテーションを作成する
    Set newtpp = tpp.Presentations.Add
    newtpp.Slides.Add 1, ppLayoutText
    'PowerPointを表示
    tpp.Visible = True
    
    'PowerPointにタイトルをコピー
    tpp.ActiveWindow.Selection.SlideRange.Shapes(1).Select
    tpp.ActiveWindow.Selection.TextRange.Text = Range("C7")
    
    'PowerPointにテキストをコピー
    tpp.ActiveWindow.Selection.SlideRange.Shapes(2).Select
    tpp.ActiveWindow.Selection.TextRange.Text = Range("C8") & vbCrLf & Range("C9")
    
    MsgBox "パワーポイントを表示しました。"
    '終了処理
    tpp.Quit
    Set newtpp = Nothing
    Set tpp = Nothing
    
End Sub



Homeに戻る > Excel プログラムのTipsへ

■■■
このサイトの内容を利用して発生した、いかなる問題にも一切責任は負いませんのでご了承下さい
■■■
当ホームページに掲載されているあらゆる内容の無許可転載・転用を禁止します


Copyright (c) Excel-Excel ! All rights reserved