That all seems fine. Under .NET 4 you can use the property indexer directly for Application.Worksheets, and Range:
[ExcelCommand(ShortCut = "^D")] // Press Ctrl+Shift+D to run
public static void dnaMyMacro3()
{
// Using COM Automation interfaces (with a reference to Microsoft.Office.Interop.Excel)
Application app = (Application)ExcelDnaUtil.Application;
Worksheet ws = app.Worksheets["Sheet1"];
ws.Range["B2"].Value = "Hello there!";
}
[ExcelCommand(ShortCut = "^E")] // Press Ctrl+Shift+E to run
public static void dnaMyMacro4()
{
// Using the C API
ExcelReference mainSheet = (ExcelReference)XlCall.Excel(XlCall.xlSheetId, "Sheet1");
ExcelReference cellA1 = new ExcelReference(0, 0, 0, 0, mainSheet.SheetId);
cellA1.SetValue("Hello via C API");
ExcelReference cellA2 = new ExcelReference(1, 1, 0, 0, "Sheet1");
cellA2.SetValue("Hello again!");
}
-Govert