A
Andrew Wiles
Hi
I have a VSTO application for Word 2007 and would like to add a chart,
embedded in a content control, without requiring the user to interact with
Excel. The following code will do this BUT when the user selects the chart
the "Office Button" disappears and an old style File menu is displayed above
the ribbon menu. It may be significant that when this happens the ribbon tab
for our application also disappears.
Is there a ay to stop this happening (or an alternate approach for adding
charts)?
Globals.ThisAddIn.Application.ScreenUpdating = true;
//// Add an Excel chart object
object objClassType = "Excel.Chart.8";
object objTrue = true;
object objFalse = false;
object objRange = contentControl.Range;
Globals.ThisAddIn.Application.ScreenUpdating = false;
Word.InlineShape ils =
contentControl.Range.InlineShapes.AddOLEObject(ref objClassType, ref missing,
ref objFalse, ref missing, ref missing, ref missing,
ref missing,
ref objRange);
Word.OLEFormat of = ils.OLEFormat;
ils.Width = 400; // TODO: Width of 400 is a compromise.
May want to see if we can calculate a accurate value...
Globals.ThisAddIn.Application.ScreenUpdating = false;
// Get the internal OLE object to be used with
Reflection (late-binding)
object obj = of.Object;
Excel.Workbook wb = null;
wb = (Excel.Workbook)obj;
wb.Application.ScreenUpdating = false;
Excel.Chart chart = (Excel.Chart)wb.Charts[1];
chart.ChartType = Excel.XlChartType.xl3DColumnStacked;
I have a VSTO application for Word 2007 and would like to add a chart,
embedded in a content control, without requiring the user to interact with
Excel. The following code will do this BUT when the user selects the chart
the "Office Button" disappears and an old style File menu is displayed above
the ribbon menu. It may be significant that when this happens the ribbon tab
for our application also disappears.
Is there a ay to stop this happening (or an alternate approach for adding
charts)?
Globals.ThisAddIn.Application.ScreenUpdating = true;
//// Add an Excel chart object
object objClassType = "Excel.Chart.8";
object objTrue = true;
object objFalse = false;
object objRange = contentControl.Range;
Globals.ThisAddIn.Application.ScreenUpdating = false;
Word.InlineShape ils =
contentControl.Range.InlineShapes.AddOLEObject(ref objClassType, ref missing,
ref objFalse, ref missing, ref missing, ref missing,
ref missing,
ref objRange);
Word.OLEFormat of = ils.OLEFormat;
ils.Width = 400; // TODO: Width of 400 is a compromise.
May want to see if we can calculate a accurate value...
Globals.ThisAddIn.Application.ScreenUpdating = false;
// Get the internal OLE object to be used with
Reflection (late-binding)
object obj = of.Object;
Excel.Workbook wb = null;
wb = (Excel.Workbook)obj;
wb.Application.ScreenUpdating = false;
Excel.Chart chart = (Excel.Chart)wb.Charts[1];
chart.ChartType = Excel.XlChartType.xl3DColumnStacked;