Web Service failed to create Excel Automation Instance Var.

pagum904
pagum904 Posts: 2
edited 2011-10-17 in NAV Three Tier
Hi All,

I am testing a sample Console application code in .Net to create a Excel worksheet from NAV using the webservice. Below is the code sample.

.Net Code :
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Sample_Demo
{
using localhost;
class Program
{
static void Main(string[] args)
{
DemoCU ws = new DemoCU();
ws.UseDefaultCredentials = true;
ws.Url = "http://localhost:7047/DynamicsNAV/WS/CronusIndiaLtd/Codeunit/DemoCU";
string OutputString = "";
try
{
OutputString = ws.CreateExcel();
}
catch (Exception e)
{
Console.WriteLine(e.Message.ToString());
}
Console.WriteLine("Result: {0}", OutputString);
Console.ReadLine();
}
}
}

NAV Code


CreateExcel() : Text[250]
CLEAR(excel);

CREATE(excel);
book:=excel.Workbooks.Add;
sheet:=excel.ActiveSheet;
FileName := 'D:\WSExcel.xls';

sheet.Range('A1').Value := 'WS Test';

sheet.SaveAs(FileName,56);
book.Close;
excel.Quit;

EXIT('Success');

But while debugging the .Net code, Webservice is failed to create the instance of the Automation Variable.
Below is the error message

"This message is for C/AL Programmers: Unable to create an instance of Automation Server Microsoft Office Excel Application with CLSID = 00024500-0000-0000-c000-000000000046 Retrieving the COM class factory for component with CLSID {00024500-0000-0000-c000-000000000046} failed due to the following error: 80070005.."

Please can any one tell how Webservice will use the Automation variables written in NAV.

Thanks in Advance

Comments