アプリ版:「スタンプのみでお礼する」機能のリリースについて

エクセルのVBAで開いているパワーポイントのファイルを印刷することは可能でしょうか?
色々とHP等で調べましたが、わかりません
教えてください

A 回答 (4件)

お、まだあきらめないんですね。


難しいでしょうが、がんばってください。

Sub pp_Print4()
Dim objPPT As Object '参照設定していればPowerPoint.Application
Dim myPre As Object 'PowerPoint.Presentation
Dim myName As String
Dim n As Long
myName = "E:\office\powerpoint\0.ppt" 'ファイル名
Set objPPT = CreateObject("PowerPoint.Application")
With objPPT
 .Visible = True
 On Error GoTo Err_Hnd
 'ファイル開いているとき
 Set myPre = .Presentations(myName)
 GoTo tugi
Err_Hnd:
 'ファイル開いていないとき
 Set myPre = .Presentations.Open(myName)
tugi:
 On Error GoTo 0
End With
With myPre
 '用紙に合わせる
 .PrintOptions.FitToPage = msoTrue
 .PrintOut '印刷
 DoEvents
 .Close 'ファイル閉じる
End With
'PowerPoint終了
objPPT.Quit
Set myPre = Nothing
Set objPPT = Nothing
End Sub
    • good
    • 0

pp_Print3で.Closeを忘れました。


↓こっちでお願いします。

Sub pp_Print3()
Dim myPre As Object 'powerpoint.Presentation
Dim n As Long
'ファイル名指定する場合
On Error GoTo Err_Hnd
Set myPre = GetObject("E:\office\powerpoint\0.ppt")
On Error GoTo 0
With myPre
.Application.Visible = True
 With .PrintOptions
  '用紙に合わせる
  .FitToPage = msoTrue
 End With
 .PrintOut '印刷
 DoEvents
 .Close
End With
Err_Hnd:
Set myPre = Nothing
End Sub

この回答への補足

ありがとうございます。
パワーポイントの「閉じる」ですが、開いている特定のファイルは閉じますが、パワーポイントのソフト自体が残ってしまいます。
パワーポイント自体を閉じるにはどうすればいいのでしょうか?

補足日時:2009/01/24 16:57
    • good
    • 0

Sub pp_Print2()


Dim objPPT As Object '参照設定していればpowerpoint.Application
Dim n As Long
'起動しているPowerPoint取得
On Error GoTo Err_Hnd
Set objPPT = GetObject(, "PowerPoint.Application")
On Error GoTo 0
With objPPT.Presentations(1) 'ひとつ目のファイルだけ
 With .PrintOptions
  '用紙に合わせる
  .FitToPage = msoTrue
 End With
 .PrintOut '印刷
 DoEvents
End With
Err_Hnd:
Set objPPT = Nothing
End Sub

Sub pp_Print3()
Dim myPre As Object 'powerpoint.Presentation
Dim n As Long
'ファイル名指定する場合
On Error GoTo Err_Hnd
Set myPre = GetObject("E:\office\powerpoint\0.ppt")
On Error GoTo 0
With myPre
 With .PrintOptions
  '用紙に合わせる
  .FitToPage = msoTrue
 End With
 .PrintOut '印刷
 DoEvents
End With
Err_Hnd:
Set myPre = Nothing
End Sub
    • good
    • 0

開いているファイルをすべて印刷するなら..



Sub pp_Print()
Const ppPrintOutputSixSlideHandouts = 4
Dim objPPT As Object 'パワポに参照設定ならPowerPoint.Application
Dim myPre As Object 'PowerPoint.Presentation
Dim n As Long
'起動しているPowerPoint取得
On Error GoTo Err_Hnd
Set objPPT = GetObject(, "PowerPoint.Application")
On Error GoTo 0
With objPPT.Presentations
 For n = 1 To .Count '開いているプレゼンループ
  With .Item(n)
   With .PrintOptions
    '1枚に6スライド(例です)
    .OutputType = ppPrintOutputSixSlideHandouts
    '用紙に合わせる
    .FitToPage = msoTrue
   End With
   .PrintOut '印刷
   DoEvents
  End With
 Next n
End With
Err_Hnd:
Set objPPT = Nothing
End Sub

新しく開くならCreateObjectを使うことも。

この回答への補足

ありがとうございます。
特定のパワーポイントファイル1つを印刷するにはどうすればいいでしょうか?
また、1ページに1スライドのみ印刷したいのですが、どうすればいいでしょうか?

補足日時:2009/01/22 20:12
    • good
    • 0

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

このQ&Aを見た人はこんなQ&Aも見ています