Microsoft KB Archive/242360

= PPT2000: Creating and Altering a Graph During a Slide Show =

Article ID: 242360

Article Last Modified on 10/11/2006

-

APPLIES TO


 * Microsoft PowerPoint 2000 Standard Edition

-



This article was previously published under Q242360



SUMMARY
This article describes how to create and manipulate a Microsoft Graph object on a slide during a slide show.



MORE INFORMATION
Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements. The following macro assumes that you have linked the macro code to an action setting, either to an action button or an object on the slide itself. To start the macro, click the linked button or object.

For more information about linking macros to action controls, click Microsoft PowerPoint Help on the Help menu, type Set up a macro to run during a slide show in the Office Assistant or the Answer Wizard, and then click Search to view the topic.

You can run the following code samples during a slide show or while in slide view: Sub CreateGraph

Dim strAcell As String Dim strBcell As String Dim strCcell As String Dim strDcell As String Dim shpGraph As Shape Dim ograph As Graph.Chart Dim lHeight As Single Dim lWidth As Single Dim i As Single

' Get the slide height and width. '  lHeight = ActivePresentation.PageSetup.SlideHeight lWidth = ActivePresentation.PageSetup.SlideWidth With ActivePresentation.Slides(1).Shapes ' Create the Graph object, and resize it on the slide. '     Set shpGraph = .AddOLEObject(Left:=(lWidth / 8), _                                Top:=(lHeight / 8), _                                Width:=(lWidth / 1.3), _                                Height:=(lHeight / 1.3), _                                ClassName:="MSGraph.Chart", _                                Link:=msoFalse) End With ' Name the shape the graph object is in so that it  ' can be easily used again by other macros '  shpGraph.Name = "Graph1" ' Set ograph to the new graph we just created. '  Set ograph = shpGraph.OLEFormat.Object ' Change the chart type to a 2d column chart. '  ograph.ChartType = xlColumnClustered ' Create a new data series on row 4. Data series ' entries are in the "0" column, and are referenced ' by .Range("0#") where # is the row in the datasheet. ' Comumn titles are in row "O", and are referenced ' by .Range("$0") where "&" is the row letter. '  ograph.Application.DataSheet.Range("04").Value = "South" ' Fill the first four columns of the datasheet ' with base values in each series. '  For i = 1 To 4 ' Append the current value of "i" to a letter for a  ' Row reference. '     strAcell = "a" & i      strBcell = "b" & i      strCcell = "c" & i      strDcell = "d" & i   ' Assign a value to each cell in the data series. '     ograph.Application.DataSheet.Range(strAcell).Value = 20 * i      ograph.Application.DataSheet.Range(strBcell).Value = 20 * i      ograph.Application.DataSheet.Range(strCcell).Value = 20 * i      ograph.Application.DataSheet.Range(strDcell).Value = 20 * i   Next i   Set ograph = Nothing End Sub The following two code samples increase and decrease all the values in the graph by an increment of five. Sub ModifyValueUp Dim ograph As Graph.Chart Dim oRange As Graph.Range ' Assign ograph to the graph object. '  Set ograph = ActivePresentation.Slides(1).Shapes("Graph1").OLEFormat.Object With ograph.Application.DataSheet ' Loop through each object and increase ' the value of each cell by 5. '     For Each oRange In .Range("a1:d4") oRange.Value = oRange.Value + 5 Next oRange End With Set ograph = Nothing End Sub

Sub ModifyValueDn Dim ograph As Graph.Chart Dim oRange As Graph.Range ' Assign ograph to the graph object. '  Set ograph = ActivePresentation.Slides(1).Shapes("Graph1").OLEFormat.Object ' Loop through each object and decrease ' the value of each cell by 5 '  With ograph.Application.DataSheet For Each oRange In .Range("a1:d4") oRange.Value = oRange.Value - 5 Next oRange End With Set ograph = Nothing End Sub The following two code samples increase and decrease the values of the first data series by 10 percent: Sub ASeriesUp Dim ograph As Graph.Chart Dim oRange As Graph.Range ' Assign ograph to the graph object. '  Set ograph = ActivePresentation.Slides(1).Shapes("Graph1").OLEFormat.Object ' Loop through each object and increase the ' first data series the value of each cell by 10 percent. '  With ograph.Application.DataSheet For Each oRange In .Range("a1:d1") oRange.Value = oRange.Value * 1.1 Next oRange End With Set ograph = Nothing End Sub

Sub ASeriesDn Dim ograph As Graph.Chart Dim oRange As Graph.Range ' Assign ograph to the graph object. '  Set ograph = ActivePresentation.Slides(1).Shapes("Graph1").OLEFormat.Object ' Loop through each object and decrease the ' first data series the value of each cell by 10 percent. '  With ograph.Application.DataSheet For Each oRange In .Range("a1:d1") oRange.Value = oRange.Value * 0.9 Next oRange End With Set ograph = Nothing End Sub

Additional query words: vba graph chart viewgraph view ppt ppt2000 ppt2k 2k powerpnt powerpoint 2000 9.0 ppt9

Keywords: kbdtacode kbhowto kbprogramming KB242360

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.