Results 1 to 3 of 3
  1. #1
    New Lounger
    Join Date
    Feb 2003
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    create a chart from data on a file (office XP)

    Anybody know how to generate a chart from data on file automatically or know where i can find information on this?
    I want Powerpoint to create a slide with a chart from data present in a file automatically.

  2. #2
    Silver Lounger
    Join Date
    Mar 2001
    Location
    Springfield, Ohio, USA
    Posts
    2,136
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: create a chart from data on a file (office XP)

    What is your definition of automatically? Normally, in XP, you press the New-Slide button, then click on the Content icon in the slide-layout pane, then click the Insert-Chart icon on your slide, and finally use the Edit | Import File menu to get the data.

    But, if "automatically" means during a presentation, with a button, using a macro, or some similar scheme, then there is more work to do. Here are a couple of demo macros to get you started. The first creates a slide from an Excel file, but in case you need to import manually, I included a second macro that shows how to setup the same data series manually.

    Please post back and give us more details on what you really want to do. Also, I'm currently running PP97, so I haven't tested the macros on XP, but nothing can go wrong... <img src=/S/wink.gif border=0 alt=wink width=15 height=15> HTH --Sam
    <pre>Option Explicit

    Sub TestImport()

    Dim ppSlide As Slide
    Dim ppChart As Shape

    Set ppSlide = ActivePresentation.Slides.Add(Index:=1, Layout:=ppLayoutTitleOnly)
    ActiveWindow.View.GotoSlide ppSlide.SlideNumber
    Set ppChart = ppSlide.Shapes.AddOLEObject(Left:=120, Top:=140, Width:=480, _
    Height:=320, ClassName:="MSGraph.Chart", Link:=msoFalse)
    With ppChart
    .OLEFormat.Activate
    With .OLEFormat.Object
    .HasTitle = True
    .ChartTitle.Text = "File Chart"
    .Application.FileImport "c:demo.xls"
    End With
    End With
    ActiveWindow.Selection.Unselect
    Set ppChart = Nothing
    Set ppSlide = Nothing
    End Sub

    Sub TestData()

    Dim ppSlide As Slide
    Dim ppChart As Shape

    Set ppSlide = ActivePresentation.Slides.Add(Index:=1, Layout:=ppLayoutTitleOnly)
    ActiveWindow.View.GotoSlide ppSlide.SlideNumber
    Set ppChart = ppSlide.Shapes.AddOLEObject(Left:=120, Top:=140, Width:=480, _
    Height:=320, ClassName:="MSGraph.Chart", Link:=msoFalse)
    With ppChart
    .OLEFormat.Activate
    With .OLEFormat.Object
    .HasTitle = True
    .ChartTitle.Text = "Demo Chart"
    With .Application.DataSheet
    .Cells.Clear
    .Cells(1, 2) = "Jan"
    .Cells(1, 3) = "Feb"
    .Cells(2, 1) = "OH"
    .Cells(2, 2) = 10
    .Cells(2, 3) = 20
    .Cells(3, 1) = "IN"
    .Cells(3, 2) = 15
    .Cells(3, 3) = 20
    End With
    End With
    End With
    ActiveWindow.Selection.Unselect
    Set ppChart = Nothing
    Set ppSlide = Nothing
    End Sub</pre>

    <font face="Comic Sans MS">Sam Barrett, CACI </font face=comic>
    <small>And the things that you have heard... commit these to faithful men who will be able to teach others also. 2 Timothy 2:2</small>

  3. #3
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: create a chart from data on a file (office XP)

    > Sub TestData()

    <pre>For I = 1 to (1/0)
    Debug.Print "Thank You"
    Next I
    </pre>


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •