1

Access のグラフからプログラムで PowerPoint を作成しようとしています。理想的には、グラフが PowerPoint に移行したときに、アクセス データにリンクされたままのグラフではなく、静的な画像になります。

次のような手順を試しました。

 Private Sub Command1_click()
     Dim pwrpnt as Object
     Dim Presentation as Object

     set pwrpnt = CreateObject("Powerpoint.Application")
     pwrpnt.Activate
     Set Presentation = pwrpnt.Presentation.Open("C:\test.ppt")
     Me.Graph1.SetFocus
     Runcommand acCmdcopy

     Presentation.Slides(1).Shapes.Paste
     set pwrpnt = Nothing
     set Presentation = Nothing
End Sub

そして、次のようなエラー メッセージが表示されます: Paste method failed.

より良いアプローチはありますか?そして、強制的に静止画像にすることはできますか?

ありがとうございました。

4

2 に答える 2

4

わかりました、私はそれを行う方法を見つけました。誰かがよりエレガントな方法を持っているかどうかはまだ興味がありますが、同様の問題を扱っている他の人にとっては:

Private Sub Command1_click()
 'Note: Sample only, in real code this should probably have something to save the 
 'PPT file and then close the powerpoint application, not to mention some error handling,
 ' and possibly some picture formatting, etc.  

 Dim pwrpnt as PowerPoint.Application
 Dim Presntation as PowerPoint.Presentation

 Me.Graph0.Action = acOLECopy
 set pwrpnt = CreateObject("Powerpoint.Application")
 pwrpnt.Activate
 Set Presentation = pwrpnt.Presentations.Open("TemplateFile.ppt")
 pwrpnt.ActiveWindow.ViewType = ppViewSlide

 'This inserts it as a picture, just use .Paste to insert it as an actual chart.
 pwrpnt.ActiveWindow.View.PasteSpecial ppPasteEnhancedMetafile 
EndSub
于 2009-06-25T23:52:56.140 に答える
2

ええ、これはまさに私が使用しているテクニックです。私は解決策を求めて Web を検索するのに何日も費やしました。あまりエレガントではありませんが、機能します。良い点は、Powerpoint で MS Graph オブジェクトを取得して、ユーザーが独自のスタイルやテンプレートなどを簡単に適用できるようにすることです。

于 2009-07-29T18:43:55.993 に答える