質問

プログラムで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メソッドが失敗しました。

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

ありがとう。

役に立ちましたか?

解決

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

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

他のヒント

はい、これはまさに私が使用している手法です-そして、解決策を探すためにウェブを検索するのに何日も費やしました。非常にエレガントではありませんが、機能します。ユーザーが独自のスタイリング、テンプレートなどを簡単に適用できるように、PowerPointでMS Graphオブジェクトを取得できるのが良い点です。

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top