Excelをまったく使用する必要はありません。 MS Access ChartsをレポートやいくつかのVBAコードで使用して、Powerpointに直接入れることができます。すでに例がありますhere
グループにグラフを生成すると、つまりグループ内のグラフでレポートを設計すると、1つの「つかみ」があります。レポートを実行すると、多数のグラフが作成されます。
これらのグラフをそれぞれ保持してPowerpointにドロップするのはちょっと難しいですが、ここではそれを処理するいくつかのコードを示します。これは、Access 2003の
'Loop through all the controls in this report and pickout all the graphs
For Each c In pReport.Controls
'Graphs initially appear to be in an Object Frame
If TypeOf c Is ObjectFrame Then
'Check the Class of the object to make sure its a Chart
If Left$(c.Class, 13) = "MSGraph.Chart" Then
'Check if this graph must be cloned (required if the graph is in a group in the MS Access report)
If Not IsGraphToBeCloned(pReport.Name, c.ControlName) Then
InsertGraphToPptSlide c, "", pReport.Name
Else
InsertGraphGroupToPpt pReport.Name, c
End If
End If
End If
Next
で動作します。このグラフは、グループ内にあるならば、我々はInsertGraphGroupToPPt関数呼び出し、レポート内のすべてのグラフを見つけるでしょう。
ここでのトリックは、同じベースグラフが複数回あることがわかっていますが、異なるデータが入力されています。だから、PowerPointのスライドをn回に基本グラフを貼り付けているあなたは何をする必要があるかPowerPointで - あなたの場合は例えば
Function UpdateGraphInPowerpoint(sql As String, OrigGraph As ObjectFrame, Groups As dao.Recordset, GroupName As String, ReportName As String) As Boolean
//Copyright Innova Associates Ltd, 2009
On Error GoTo ERR_CGFF
On Error GoTo ERR_CGFF
Dim oDataSheet As DataSheet
Dim Graph As Graph.Chart
Dim lRowCnt, lColCnt, lValue As Long, CGFF_FldCnt As Integer
Dim CGFF_Rs As dao.Recordset
Dim CGFF_field As dao.Field
Dim CGFF_PwrPntloaded As Boolean
Dim lheight, lwidth, LLeft, lTop As Single
Dim slidenum As Integer
Dim GraphSQL As String
Dim lGrpPos As Long
'Loop thru groups
Do While Not Groups.EOF
'We want content to be added to the end of the presentation - so find out how many slides we already have
slidenum = gPwrPntPres.Slides.Count
OrigGraph.Action = acOLECopy 'Copy to clipboard
slidenum = slidenum + 1 'Increment the Ppt slide number
gPwrPntPres.Slides.Add slidenum, ppLayoutTitleOnly 'Add a Ppt slide
'On Error Resume Next 'Ignore errors related to Graph caption
gPwrPntPres.Slides(slidenum).Shapes(1).TextFrame.TextRange.Text = ReportName & vbCrLf & "(" & Groups.Fields(0).Value & ")" 'Set slide title to match graph title
gPwrPntPres.Slides(slidenum).Shapes(1).TextFrame.TextRange.Font.Size = 16
gPwrPntPres.Slides(slidenum).Shapes.Paste 'Paste graph into ppt from clipboard
Set Graph = gPwrPntPres.Slides(slidenum).Shapes(2).OLEFormat.Object
Set oDataSheet = Graph.Application.DataSheet ' Set the reference to the datasheet collection.
oDataSheet.Cells.Clear ' Clear the datasheet.
GraphSQL = Replace(sql, "<%WHERE%>", " where " & GroupName & " = '" & Groups.Fields(0).Value & "'")
Set CGFF_Rs = ExecQuery(GraphSQL)
CGFF_FldCnt = 1
' Loop through the fields collection and get the field names.
For Each CGFF_field In CGFF_Rs.Fields
oDataSheet.Cells(1, CGFF_FldCnt).Value = CGFF_Rs.Fields(CGFF_FldCnt - 1).Name
CGFF_FldCnt = CGFF_FldCnt + 1
Next CGFF_field
lRowCnt = 2
' Loop through the recordset.
Do While Not CGFF_Rs.EOF
CGFF_FldCnt = 1
' Put the values for the fields in the datasheet.
For Each CGFF_field In CGFF_Rs.Fields
oDataSheet.Cells(lRowCnt, CGFF_FldCnt).Value = IIf(IsNull(CGFF_field.Value), "", CGFF_field.Value)
CGFF_FldCnt = CGFF_FldCnt + 1
Next CGFF_field
lRowCnt = lRowCnt + 1
CGFF_Rs.MoveNext
Loop
' Update the graph.
Graph.Application.Update
DoEvents
CGFF_Rs.Close
DoEvents
Groups.MoveNext
Loop
UpdateGraphInPowerpoint = True
Exit Function
End Function
を、nはグループの数で、その後、グラフのクエリのプロパティを更新これは参考になりますあなたが使用しているExcel、Accessなどの特定のバージョンを教えてくれました。 2003? 2007年?そのようにして、VBAコードの具体例を提供することができます。 – JonnyBoats
それはWindowsサーバーxpになるでしょう...私はそのMSoffice 200-2003を推測していますか? 2003私は –
本当に便利な質問だと思う!私はExcelからPowerPointへのテーブルやチャートの公開を自動化するマクロもいくつか持っていました。私はクリップボードにセルの範囲をcopiingし、次に特別なコマンドを貼り付けることでこれを行います。今私は別のアイデアを試してみましょう - 私はすべてのこれらのグラフにアクセスするレポートを作成し、アクセスからパワーポイントのスライドを生成します。 –