Hi Experts,
I have written the Below code to Import data from excel to NAV. It's Working Fine When I run manually,
But if i run that codeunit through NAS, then i got error like this
" A call to System.__ComObject.Add failed with this message: The type of one or more arguments does not match the method's parameter type. "
I changed RunOnClient Property of all dotnet variables to "NO".
But it showing the above error.
Please suggest me, How to resolve this.
Code:-
IF ISNULL(XlApp) THEN
XlApp := XlApp.ApplicationClass;
XlApp.Visible(FALSE);// Set FALSE if you don't want to show.
XlWrkBk := XlApp.Workbooks.Add(FileName);
XlWrkBk := XlApp.ActiveWorkbook;
XlWrkSht := XlWrkBk.Worksheets.Item(1);
SheetName := XlWrkSht.Name;
XlWrkSht := XlWrkBk.Worksheets.Item(SheetName);
Variables:-
Name DataType Subtype
XlApp DotNet Microsoft.Office.Interop.Excel.ApplicationClass.'Microsoft.Office.Interop.Excel, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c'
XlWrkBk DotNet Microsoft.Office.Interop.Excel.Workbook.'Microsoft.Office.Interop.Excel, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c'
XlWrkSht DotNet Microsoft.Office.Interop.Excel.Worksheet.'Microsoft.Office.Interop.Excel, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c'
*This post is locked for comments