I don't speak visual C#, but why did you change from Sheets.add to
worksheets.add.
Sheets.add can accept a template parm. Worksheets.add won't do what you want.
fenguo wrote:
>
> Can someone tell me how to create a new worksheet from a template? I hope to
> create a worksheet from a template. In VBA programe,we can use following
> code:
> Dim type1 As Variant
> type1 = "C:\Documents and Settings\new\Application
> Data\Microsoft\Templates\aaa.xlt"
> Sheets.Add , Sheets("Sheet2"), 1, type1
> But When i use following code in Visual C#:
> string ws;
> ws = "C:\\Documents and Settings\new\\Application
> Data\\Microsoft\\Templates\\成绩单模板.xlt";
> //eapp is a excel application object.
> eapp.Worksheets.Add(Missing.Value,
> eapp.Worksheets[1],Missing.Value ,ws );
> I get a COMException that HRESULT:0x800A03EC.
> Why? How can we create a new worksheet from a template by C#?
> thank you.
--
Dave Peterson
|