NAV 2009 Excel Automation

iansilversiansilvers Member Posts: 38
I hope someone can help.

I am performing an upgrade from NAV 4.02 to NAV 2009 SP1. I have a codeunit that was used to create an Excel spreadsheet using automation variables for the Excel Application, Workbook, and Sheet. I have taken the object from 4.02 and imported into 2009, and it will not compile failing with the error

"The variable XLWOOKBOOK::SHEETPIVOTTABLEBEF is defined more than once"

I have tried copying the variables from codeunit 424 and pasting into my codeunit, but still get the same error! Even copying them into an empty codeunit gives the problem

Anyone got any ideas what is happening?

Comments

  • krikikriki Member, Moderator Posts: 9,110
    Move your variable from global to local or vice versa. I also encountered the problem and this fixed it.
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • iansilversiansilvers Member Posts: 38
    Thanks for the suggestion but it is not that easy to move from Global to Local, as the variables are widely used throughout the codeunit. This does not explain why the problem does not exist in codeunit 424 which I can compile without errors!
  • Luc_VanDyckLuc_VanDyck Member, Moderator, Administrator Posts: 3,633
    Then try shorten the variable name. See also this thread: Strange error when trying to create global word automation
    No support using PM or e-mail - Please use this forum. BC TechDays 2024: 13 & 14 June 2024, Antwerp (Belgium)
  • iansilversiansilvers Member Posts: 38
    Thanks for the reply. I copied the variables from codeunit 424 which compiles correctly, but I still get the same error. So, following on from the suggestion in the Word automation topic, I have exported my codeunit as text, removed all the event handles for the automation variables and re-imported - problem gone.

    Surely by having the WithEvents set to No, it should not have created the events in the first place?
  • JDVyskaJDVyska Member Posts: 179
    Pardon for bumping the old topic, but I found this while searching for help with the same issue, but not by the key terms i was looking for. My post is just adding a few keywords to the helpful thread.


    When compiling Table 370 Excel Buffer, it would not compile with this as the error:

    Microsoft Dynamics NAV Classic
    The variable XLAPP::PROTECTEDVIEWWINDOWBEFO is defined more than once.

    An example could be: 'File' exists as both a data type and a global variable.

    OK


    Saving it uncompiled, exporting as text, deleting all the events that SHOULDN'T EVEN BE THERE (I had WithEvents to No on all of them, so annoying that it does this), and reimporting, then compiling.

    Thanks all for the help.
    JEREMY VYSKA
    CEO, Spare Brained Ideas, Göteborg, Sweden
    New (April 2021) Getting Started with Microsoft Dynamics 365 Business Central Book Available: "Your First 20 Hours with Business Central"
  • dianageledianagele Member Posts: 14
    I found a solution to this problem.
    If you log into any different non-64 bit machine, save and compile it, the report carries you around the xlapp automation error.
    d.
  • JDVyskaJDVyska Member Posts: 179
    Non-64 bit? Man, next we'll have to use a MS-DOS 6.22 compiler... :lol:

    Good to know that works too.
    JEREMY VYSKA
    CEO, Spare Brained Ideas, Göteborg, Sweden
    New (April 2021) Getting Started with Microsoft Dynamics 365 Business Central Book Available: "Your First 20 Hours with Business Central"
  • mark_aumark_au Member Posts: 40
    Pretty sure this is an issue in the NAV 2009 client:

    https://mbs.microsoft.com/knowledgebase/KBDisplay.aspx?scid=kb;EN-US;2256756
  • dianageledianagele Member Posts: 14
    Well, I'm not sure if it is exclusive to the 2009 client; same thing for me (64 bit and have Nav 5).
  • mark_aumark_au Member Posts: 40
    Yes that's correct, it's not exclusive to 2009 (check the linked KB, mentions 5 also), but the OP is using 2009 so that's where it's relevant :D
Sign In or Register to comment.