Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics NAV (Archived)

ERROR GOT WHEN IMPORT EXCEL DATA FROM NAV 2016 THROUGH NAS

(0) ShareShare
ReportReport
Posted on by

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

  • Verified answer
    Binesh Profile Picture
    Binesh 7,885 on at
    RE: ERROR GOT WHEN IMPORT EXCEL DATA FROM NAV 2016 THROUGH NAS

    Hello Satya,

    Use Table 1234 "CSV Buffer" for Loading the CSV file and then insert into table as you want.

    once the table updated then use Excel Buffer Table to update, for reference see bellow screenshot.

    2day.jpg

  • RE: ERROR GOT WHEN IMPORT EXCEL DATA FROM NAV 2016 THROUGH NAS

    Hi All,

    Please let me know, Is there any alternative for Add method.

    It's my urgent requirement.

    If i run manually everything is working fine, I got problem when i run through NAS.

    Also I tried with Excel Buffer methods through NAS. It's Working.

    But the Problem is it's working for '.xls' files, if i use '.csv' files it's not working.

    So I can't use Excel Buffer methods.

    I can use XlApp, XlWrkBk, XlWrkSht  variables.

    So I need alternative for Add method

    Please let me know how to resolve this issue.

    Thanks.

  • RE: ERROR GOT WHEN IMPORT EXCEL DATA FROM NAV 2016 THROUGH NAS

    Thanks for your response RockWith NAV

    I got the error at the following line

    XlWrkBk := XlApp.Workbooks.Add(FileName);

    Add Method doesn't work.

    I need to import data and update excel data daily,So  It's done through NAS.

    Anyone reached this requirement in NAV 2016 Please suggest me - How to do.

    Thanks.

  • Suggested answer
    RockwithNav Profile Picture
    RockwithNav 6,562 on at
    RE: ERROR GOT WHEN IMPORT EXCEL DATA FROM NAV 2016 THROUGH NAS

    Did you tried enabling Debugger and to cross verify on which Line of Code does it stops??

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,516 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,409 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans