Excel Automation - Import file with NAV-code

neckitneckit Member Posts: 24
I have a Codeunit which exports some tabledata from Navision to Excel with the functions of the ExcelBuffer-Table (Table 370). This works great.
But now i have one table with over 10.000 records and the performance of the export is terrible.

Now im trying to export the records in a csv-File and import them to Excel with a special function in the ExcelBuffer-Table. The export to the csv-File is ok. But i don't know, how I can import the file in Excel with Navision-Code.
Because the Excel-File has several Sheets i can't open the csv-File directly and i also don't want to use a macro in this Excel-File.
Instead of that, I want to import the csv-File to Excel with a new function in the ExcelBuffer-Table.

Excel would use the following Macro-Code.
Is there a way to write this as Function in the ExcelBuffer-Table?
With ActiveSheet.QueryTables.Add(Connection:="TEXT;C:\Test.csv",Destination _
    :=Range("$A$1"))
    .Name = "Test"
    .FieldNames = True      
    {...}
End With

I don't find the right syntax in NAV-Code.
Please help me.

thanks
Ralf

Comments

  • girish.joshigirish.joshi Member Posts: 407
    You can look at how NAV does this in the RIM tookit objects.
  • neckitneckit Member Posts: 24
    You can look at how NAV does this in the RIM tookit objects.

    I don't have the RIM toolkit - because i'm not a MS-Partner.

    It would be great, if you can give me the necessary code out of the RIM toolkit?

    Ralf
  • Slawek_GuzekSlawek_Guzek Member Posts: 1,690
    Hi,
    You need to create automation variable which has Worksheet object. Then you need to instatianate it (by calling CREATE(yourWorksheetAutomationVariable) ) you may call
    yourWorksheetAutomationVariable.ActiveSheet.QueryTables.Add(Here you have to put _every_ single parameter for Add function, required and optionals)
    

    If the parameter is defined as byVar you need to create a new variable in the code, and use variable in function call even if it has constant or NULL value.

    Look deeper into Table 370 functions for correct syntax, or here: http://www.mibuso.com/dlinfo.asp?FileID=811

    Regards,
    Slawek
    Slawek Guzek
    Dynamics NAV, MS SQL Server, Wherescape RED;
    PRINCE2 Practitioner - License GR657010572SG
    GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-03
Sign In or Register to comment.