web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

The class 'SysExcelWorkbooks' does not contain the method itemFromNum

(0) ShareShare
ReportReport
Posted on by 511

Good day folks,

I am writing an Excel import class in Ax 2012 R2 and I'm having an issue with SysExcelWorkbooks trying to access itemFromNum() with the below error.

0066.pastedimage1669574426959v1.png

Is there anything with the code I have written, which is below?

    SysExcelApplication     _application;
    SysExcelWorkbooks       _workbooks;
    SysExcelWorkbook        _workbook;
    SysExcelWorksheets      _worksheets;
    SysExcelWorksheet       _worksheet;
    SysExcelCells           _cells;
	
	//table names and EDT declaration omitted here
   
    COMVariantType          _type;
    int rowCount=1;
   
    container      _conFilter = ["(.xls)" ,"*.xlsx"];
  
    FileName        _fileName;
    Dialog          _dialog;
    DialogField     _dialogfield;
    _dialog = new Dialog();
    _dialog.caption("Pick a file");
    _dialogfield = _dialog.addField(extendedTypeStr(FilenameOpen));
    _dialog.filenameLookupFilter(conFilter);
    _dialog.run();

    if(_dialog.closedOk())
    {
        _fileName = _dialogfield.value();
        _application = SysExcelApplication::construct();

        _workbooks = _application.workbooks();
       
        try
        {
            _workbooks.open(_fileName);
        }
        catch (Exception::Error)
        {
            throw error("Could not open the excel upload file");
        }
        _workbook    = _workbooks.item(1);
        _worksheets  = _workbook.worksheets();
        _worksheet   = _worksheets.itemFromNum(1);
		
		
		//more code here
		
		}

Thank you in advance for your help!

I have the same question (0)
  • André Arnaud de Calavon Profile Picture
    304,459 Super User 2026 Season 1 on at

    Moved the question from the Dynamics 365 Finance to the Dynamics AX forum.

  • Suggested answer
    GirishS Profile Picture
    27,843 Moderator on at

    Hi Huggins,

    Error shown in the screenshot and your code is contradictory. Error says itemFromNum method in SysExcelWorkbook doesn't exist, but in your code there is such any.

    Try to recompile the code - If it doesn't help just close and reopen the ax and try compiling again.

    Thanks,

    Girish S.

  • Verified answer
    Huggins Mafigu Profile Picture
    511 on at

    I got the problem, instead of doing 

    _worksheet   = _worksheets.itemFromNum(1);
    , I wrote it as 
    _worksheet   = _workbook.itemFromNum(1);
    .

    All along I was overlooking this part.

    Thank you for your help!

  • André Arnaud de Calavon Profile Picture
    304,459 Super User 2026 Season 1 on at

    Hi Huggins,

    I was trying to start and update my (old) AX 2012 demo environment to check what might be missing. My license expired and I have to update it to be able to access the AOT. In the meantime, you found your answer.

    Thanks for providing your own answer. I have marked your question as verified, so the status of the question will be answered.

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 627

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 615 Super User 2026 Season 1

#3
CP04-islander Profile Picture

CP04-islander 301

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans