F
fenguo
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.
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.