Results 1 to 4 of 4
  1. #1
    Star Lounger
    Join Date
    Mar 2008
    Posts
    98
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I'm trying to figure out the best way to have excel provide a chart export option, such as exporting a chart to power point, word or outlook. I've got a method that works for both power point and word but I don't think these are the best or most effecient ways to do this. Below is what I have so far and any suggestions to improve this or other options that seem to work better would be appreciated. I'm also looking to find the best way to center a chart on the power point slide or word document.

    To export to Power Point.

    Sub Export_2PP()
    Application.ScreenUpdating = False
    C2E = Worksheets("CC").Range("I12").Value ' This is a cell where the chart name is stored (Chart 1)
    ActiveSheet.ChartObjects(C2E).Activate
    ActiveChart.Parent.Copy
    Set Pwr = CreateObject(Class:="PowerPoint.Application")
    Pwr.Visible = True
    Pwr.Presentations.Add
    Pwr.ActivePresentation.Slides.Add Index:=1, Layout:=12
    Pwr.ActiveWindow.View.Paste

    ' This section attempts to center the chart but I think this could be improved upon.

    With Pwr.ActiveWindow.Selection.ShapeRange
    .Left = 100
    .Top = 60
    .Width = 500
    .Height = 300
    .Width = 500
    End With
    Application.ScreenUpdating = True
    End Sub



    [u]To export to Word document.[/u]

    Sub Export_2Word()
    Application.ScreenUpdating = False
    C2E = Worksheets("CC").Range("I12").Value
    ActiveSheet.ChartObjects(C2E).Activate
    ActiveChart.Parent.Copy
    Set Wrd = CreateObject(Class:="Word.Application")
    Wrd.Visible = True
    Wrd.Documents.Add DocumentType:=wdNewBlankDocument
    Wrd.Selection.Paste

    ' This section attempts to center the chart but I think this could be improved upon.

    With Wrd.ActiveWindow.Selection.ShapeRange
    .Left = 100
    .Top = 60
    .Width = 500
    .Height = 300
    .Width = 500
    End With
    Application.ScreenUpdating = True
    End Sub



    The method I was looking at for exporting a chart to outlook doesn't see to work with a chart object. It only wants to export text or a range of text. Any help on how to export a chart into and email would be appreciated.


    Thanks so much for any help or suggestions to improve this.

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 16 Times in 16 Posts
    You can replace the two lines

    ActiveSheet.ChartObjects(C2E).Activate
    ActiveChart.Parent.Copy

    with

    ActiveSheet.ChartObjects(C2E).Copy

    For PowerPoint, you could use Pwr.ActivePresentation.PageSetup.SlideWidth and Pwr.ActivePresentation.PageSetup.SlideWidth in combination with the width and height of the chart object to center it.

  3. #3
    Star Lounger
    Join Date
    Mar 2008
    Posts
    98
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hans,

    Thanks for the suggestions. Is it possible to export and excel chart to and outlook email? I've only been able to export text or a range of text.

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 16 Times in 16 Posts
    The Outlook object model doesn't really provide for this. You could save the chart to a file, using the Export method of the Chart object, and add it to the Attachments collection of a mail message.

Posting Permissions

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