none
Word VBA create a chart RRS feed

  • Question

  • What's the best method to create a chart in Word?

    I bump to this link: https://msdn.microsoft.com/en-us/library/office/ff629397(v=office.14).aspx

    But it looks like it's getting the values from a workbook.

    Is there a way to create a chart in Word using dynamic values?

    When the graph is created all data will be discarded.

    Please help. Thanks.


    Every second counts..make use of it. Disclaimer: This posting is provided AS IS with no warranties or guarantees and confers no rights.

    Wednesday, August 23, 2017 9:43 AM

Answers

  • Hi cguan,

    ->Is there a way to create a chart in Word using dynamic values?

    ChartData of a Word Chart object is stored in a workbook, it is determined by design. So, I think you have to adjust your dynamic data to fill in the workbook as the link shows.

    ->When the graph is created all data will be discarded.

    What do you mean this? Maybe, you could save the chart as picture so it will show as the chart created and won't have any data source. Here is the example.

    Dim wdChart As Chart
    
    Dim ishp As InlineShape
    
    Set ishp = ActiveDocument.InlineShapes(1)
    
    Set wdChart = ishp.Chart
    
    wdChart.Copy
    
    ishp.Select
    
    Selection.PasteSpecial datatype:=wdPasteMetafilePicture
    
    ishp.Delete

    Best Regards,

    Terry

    • Marked as answer by cguan Thursday, August 24, 2017 7:48 AM
    Thursday, August 24, 2017 2:48 AM

All replies

  • Hi cguan,

    ->Is there a way to create a chart in Word using dynamic values?

    ChartData of a Word Chart object is stored in a workbook, it is determined by design. So, I think you have to adjust your dynamic data to fill in the workbook as the link shows.

    ->When the graph is created all data will be discarded.

    What do you mean this? Maybe, you could save the chart as picture so it will show as the chart created and won't have any data source. Here is the example.

    Dim wdChart As Chart
    
    Dim ishp As InlineShape
    
    Set ishp = ActiveDocument.InlineShapes(1)
    
    Set wdChart = ishp.Chart
    
    wdChart.Copy
    
    ishp.Select
    
    Selection.PasteSpecial datatype:=wdPasteMetafilePicture
    
    ishp.Delete

    Best Regards,

    Terry

    • Marked as answer by cguan Thursday, August 24, 2017 7:48 AM
    Thursday, August 24, 2017 2:48 AM
  • Hi Terry, I thought I am unable to edit the data, but I can right click and do any changes.

    Every second counts..make use of it. Disclaimer: This posting is provided AS IS with no warranties or guarantees and confers no rights.

    Thursday, August 24, 2017 7:48 AM