none
How to create chart on a MSWord doc? RRS feed

  • Question

  • Hi every body.

    I've generated a word reporting class, and need to create some chart on it.

    I searched the forum and figured out that it should be like below:

    oDoc.Range.InlineShapes.AddChart(XLChartType....

    The best overload for InlineShapes.Add gets two arguments:

    1- An argument of type XLChartType

    2- A Variant arument

    It seems to me that XLChartType enumeration is defined at Microsoft.Office.Core namespace (office.dll) or Microsoft.Office.Interop.Excel namespace, but there is no definition of that enumeration at none of these.

    Could anyone help me on this issue? I need to know where is XLChartType enumeration defined exactly, and which dll I have to reference?

    I'll appreciate that greatly.





    • Edited by a.hajihasani Wednesday, December 3, 2014 11:58 AM
    Tuesday, December 2, 2014 12:52 PM

All replies

  • Hi,

    Base on my research, there isn’t Add method in InlineShares. How/Where do you get that method?

    # InlineShapes methods

    http://msdn.microsoft.com/en-us/library/Microsoft.Office.Interop.Word.InlineShapes_methods(v=office.15).aspx

    There is AddChart method and the first parameter is XlChartType, this enum type is in Microsoft.Office.Core (office.dll), we should access and use this enumeration from the Excel primary interop assembly (PIA). I suggest that you could use this method.

    More information about XlCharType enumeration, please refer to:

    # XlChartType enumeration

    http://msdn.microsoft.com/EN-US/library/ff558127  

    On the other hand, about creating charts in word, please refer to:

    # Creating Charts with VBA in Word 2010

    http://msdn.microsoft.com/en-us/library/office/ff629397(v=office.14).aspx

    Best Regards

    Starain


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Wednesday, December 3, 2014 6:59 AM
    Moderator
  • Thanks dear Starain.

    InlineShapes.Add() method Corrected to InlineShapes.AddChart() method.

    I'm already using "C:\Program Files\Microsoft Visual Studio 10.0\Visual Studio Tools for Office\PIA\Office12\Office.dll" as Office reference and refer to it by "using Microsoft.Office.Core" statement. But the Microsoft.Office.Core does not contain XlChartType enumeration! It seems strange to me. That was the problem that made me to send this post!



    • Edited by a.hajihasani Wednesday, December 3, 2014 12:08 PM
    Wednesday, December 3, 2014 11:59 AM
  • Hi,

    Base on my test in VS2010 and VS2008, I can access XLChartType enum. (using office 12.0.0.0 assembly)

    Please create a simple project (could reproduce that issue) and share on the OneDrive, we will check it.

    Best Regards

    Starain


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, December 4, 2014 7:28 AM
    Moderator