NAV2013 automation - setfilter

CaponeCapone Member Posts: 125
edited 2013-01-21 in NAV Three Tier
Hi,

I'm testing to migrate a piece of code to NAV 2013
Office_Version := 0;

Automation_Server.SETFILTER(Name,'Microsoft Excel 8.0 Object Library');
IF Automation_Server.FINDFIRST THEN
  Office_Version := 1;
Automation_Server.SETFILTER(Name,'Microsoft Excel 9.0 Object Library');
IF Automation_Server.FINDFIRST THEN
  Office_Version := 2;
Automation_Server.SETFILTER(Name,'Microsoft Excel 10.0 Object Library');
IF Automation_Server.FINDFIRST THEN
  Office_Version :=3;
Automation_Server.SETFILTER(Name,'Microsoft Excel 11.0 Object Library');
IF Automation_Server.FINDFIRST THEN
  Office_Version := 4;
Automation_Server.SETFILTER(Name,'Microsoft Excel 12.0 Object Library');
IF Automation_Server.FINDFIRST THEN
  Office_Version := 5;
Automation_Server.SETFILTER(Name,'Microsoft Excel 14.0 Object Library');
IF Automation_Server.FINDFIRST THEN
  Office_Version := 6;

When I run this I get something like this (translated) "The type Record2000000046() is aged"

When I debug it sticks on Automation.setfilter. So why does it complain on this when the datatype allows this in the symbol menu? :-k
Hello IT, have you tried to turn it off and on?
Have you checked the cables?
Have you released the filters?

http://www.navfreak.com

Answers

  • rikardhrikardh Member Posts: 11
    There is two DotNet datatypes you can use.

    Declare 2 variables
    WordHelper - DotNet - Microsoft.Dynamics.Nav.Integration.Office.Word.WordHelper. 'Microsoft.Dynamics.Nav.Integration.Office, Version=7.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
    
    WordApplication - DotNet - Microsoft.Office.Interop.Word.ApplicationClass. 'Microsoft.Office.Interop.Word, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c'	
    

    Then the code:
    WordApplication := WordApplication.ApplicationClass;
    MESSAGE('%1',WordApplication.Version)
    

    Will show the office version, in my environment 14.0 (office 2010)

    Check in codeunit 5054 WordManagement for other stuffs about office integration.
  • CaponeCapone Member Posts: 125
    Great, it worked.

    Cheers!
    Hello IT, have you tried to turn it off and on?
    Have you checked the cables?
    Have you released the filters?

    http://www.navfreak.com
Sign In or Register to comment.