Convert Visual Basic for Applications Macro to C# 4.0

In this post I am go Convert Visual Basic for Applications Macro to C# 4.0 , This is really easy one. I include youtube Video also..

See this video :-
[youtube=http://www.youtube.com/watch?v=at_ExhQLgm4]
VBA macro code :-


Sub Macro1()
ActiveCell.FormulaR1C1 = "1"
Range("A2").Select
ActiveCell.FormulaR1C1 = "2"
Range("A1:A2").Select
Selection.AutoFill Destination:=Range("A1:A10"), Type:=xlFillDefault
Range("A1:A10").Select
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorAccent1
.TintAndShade = 0.399945066682943
.PatternTintAndShade = 0
End With
Range("A1:A10").Select
ActiveSheet.Shapes.AddChart.Select
ActiveChart.ChartType = xlConeColStacked
ActiveChart.SetSourceData Source:=Range("Sheet1!$A$1:$A$10")
End Sub

C# code:- small change, it is very easy..
We must import Microsoft.Office.Interop.Excel..


using Excel = Microsoft.Office.Interop.Excel;
class Program
{
static void Main(string[] args)
{
var excelApp = new Excel.Application();
excelApp.Workbooks.Add();
excelApp.ActiveCell.FormulaR1C1 = "1";
excelApp.Range["A2"].Select();
excelApp.ActiveCell.FormulaR1C1 = "2";
excelApp.Range["A1:A2"].Select();
excelApp.Selection.AutoFill(
Destination: excelApp.Range["A1:A10"],
Type: Excel.XlAutoFillType.xlFillDefault);
excelApp.Range["A1:A10"].Select();
excelApp.Selection.Interior.Pattern = Excel.Constants.xlSolid;
excelApp.Selection.Interior.PatternColorIndex = Excel.Constants.xlAutomatic;
excelApp.Selection.Interior.ThemeColor = Excel.XlThemeColor.xlThemeColorAccent1;
excelApp.Selection.Interior.TintAndShade = 0.399945066682943;
excelApp.Selection.Interior.PatternTintAndShade = 0;
excelApp.Range["A1:A10"].Select();
excelApp.ActiveSheet.Shapes.AddChart.Select();
excelApp.ActiveChart.ChartType = Excel.XlChartType.xlConeColStacked;
excelApp.ActiveChart.SetSourceData(Source: excelApp.Range["Sheet1!$A$1:$A$10"]);
excelApp.Visible = true;
}
}

You can get more detail and my source is
http://blogs.msdn.com/b/csharpfaq/archive/2010/09/28/converting-a-vba-macro-to-c-4-0.aspx
Video :-
http://msdn.microsoft.com/en-us/vcsharp/ff962528.aspx

Thanks,
Naga Harish.