Excel 12 - Automate simple excel tasks RRS feed

  • Question

  • I am having a few problems with automating some simple excel tasks.

    Problem 1: I have an excel workbook with 4 sheets and I would like to reorder the sheets but the oSheet.Index property is readonly and has no set method.

    Problem 2: I have written the following function for creating pie charts, but if I call it multiple times the charts sit on top of each other and have to be manually repositioned so that they are all visible. Is their a way of programmatically moving a chart to position x, y?

    private void createPieChart(Excel._Worksheet oWS)  
        Excel._Workbook oWB;  
        Excel.Range oResizeRange;  
        Excel._Chart oChart;  
        //Add a Chart for the selected data.  
        oWB = (Excel._Workbook)oWS.Parent;  
        oChart = (Excel._Chart)oWB.Charts.Add(Missing.Value, Missing.Value, Missing.Value, Missing.Value);  
        //Use the ChartWizard to create a new chart from the selected data.  
        oResizeRange = oWS.get_Range("A3:B4", Missing.Value).get_Resize(Missing.Value, Missing.Value);  
        oChart.ChartWizard(oResizeRange, Excel.XlChartType.xl3DPie, Missing.Value, Excel.XlRowCol.xlColumns, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value);  
        // Set chart title  
        oChart.HasTitle = true;  
        oChart.ChartTitle.Caption = "Project Status";  
        oChart.Location(Excel.XlChartLocation.xlLocationAsObject, oWS.Name);  

    Problem 3: I want the created pie charts to display percentages but I cannot find a property like oChart.Labels.Percentages = true;

    Any help would be greatly appriachated.
    Cathal Coffey
    • Moved by Peter Ritchie Tuesday, August 19, 2008 5:26 PM Question is better addressed by another forum. (Moved from Visual C# General to Off-Topic Posts (Do Not Post Here))
    Tuesday, August 19, 2008 4:42 PM