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

表題の件、質問します。

困っている事が4点あります。
1.PowerPointへ挿入したテキストのサイズを変更したい
2.PowerPointへ挿入したテキストのフォントを変更したい
3.PowerPointへ挿入したグラフのサイズを変更したい
4.powerpointを名前を付けて、指定の場所へ保存
以上、宜しくお願いします。

参考にコードを記述します。
Sub test()
Dim app As PowerPoint.Application
Dim pre As PowerPoint.presentation

Set app = CreateObject("powerpoint.application")
app.Visible = True

Set pre = app.Presentations(1)
app.Presentations(1).Slides(1).Shapes.AddTextbox(msoTextOrientationHorizontal _
, 100, 100, 200, 50).TextFrame.TextRange.Text = "図1"
'↑ここで作成したテキストのサイズを変更
'↑ここで作成したテキストのフォントを変更(例:MS 明朝)

   
Worksheets("グラフ").Shapes(1).CopyPicture
pre.Slides(1).Shapes.Paste
pre.Slides(1).Shapes(1).Left = 180
pre.Slides(1).Shapes(1).Top = 150
'↑ここで挿入したグラフのサイズを変更(例:縦横50%へ)

'最後に、名前を付けて指定の場所へ保存
End Sub

※マクロ起動条件:
 1.excelに"グラフ"のsheetがある事
 2.sheet内にグラフがある事
 3.powerpointを開いていること(スライドが1枚ある事)

A 回答 (2件)

保存は プレゼンテーションオブジェクトの Save、SaveAsなどのメソッド使えば可能だと思いますよ



pre.Save "MyTest.ppt"
といった具合で ・・・
    • good
    • 0

PowerPointの参照設定をしているのであれば



> app.Presentations(1).Slides(1).Shapes.AddTextbox(msoTextOrientationHorizontal _
, 100, 100, 200, 50).TextFrame.TextRange.Text = "図1"
一気に記述するより Withや PowerPoint.Shapeで受けて操作しましょう
dim sh as PowerPoint.Shape
set sh = app.Presentations(1).Slides(1).Shapes. _
  AddTextbox(msoTextOrientationHorizontal, 100, 100, 200, 50)
with sh.TextFrame.TextRange
  .Text = "図1"
  .Font.Size = 24
  .Font.Name = "MS 明朝"
End With

同様に グラフは Pasteの戻り値 ShapeRangeで受け取ります
Dim shr as PowerPoint.ShapeRange
Worksheets("グラフ").Shapes(1).CopyPicture
Set shr = pre.Slides(1).Shapes.Paste
shr.Left = 180
shr.Top = 150
shr.LockAspectRatio = msoTrue
' WidhかHeightのどちらか一方を設定
' 両方実行すると1/4になるので注意
shr.Width = shr.Width / 2
'shr.Height = shr.Height / 2

といった具合でしょう
    • good
    • 0
この回答へのお礼

ありがとうございます。
困っていた3点は解決しましたが、
最後の保存に関するところが・・・
わかれば、回答お願い致します。

お礼日時:2008/07/07 13:02

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