Error at compile object has automation variable type MSWord

jemmyjemmy Member Posts: 247
Folks,

Found a little trouble again within Navision Integration. :x

Navision : W1370
OCX : Microsoft Word 11.0 Object Library.

Variable name : MSWordApp
DataType : Automation
SubType : 'Microsoft Word 11.0 Object Library'.Application

When I compile the object, it will give an error:
The variable MSWORDAPP::MAILMERGEDATASOURCE is defined more than once.
An Example could be: 'File' exists as both a data type and a global variable
.

Anyone know how to figure this out? :roll:

Thank in advance as always,

Jemmy

edited:
after I rechecked the C/Al code of the form, I found that:
MSWordApp::MailMergeDataSource(Doc : Automation "'Microsoft Word 11.0 Object Library'.Document")

MSWordApp::MailMergeDataSource(Doc : Automation "'Microsoft Word 11.0 Object Library'.Document";VAR Handled : Boolean)

But, we can't delete one of the line, since this function build in .dll, how to resolve this? :?:

Comments

  • DenSterDenSter Member Posts: 8,304
  • AngeloAngelo Member Posts: 180
    hello,Jemmy

    Anda pasti memakai WithEvents. I ever met problem like you but I "rebuild" a new variable type automation(word) again and it work again.
  • jemmyjemmy Member Posts: 247
    Daniel,

    In this case, I used Form 21 Customer Card.
    And I put the C/Al code in the menu button Customer to open MS.Word.
    But I think this is not caused by Form, is it? :roll:

    Angelo,
    Rebuild? Do you mean I have to delete and create again?
    I have tried but nothing changed. :(

    Anyway thanks.. and hope to hear from you soon.

    Jemmy
  • Timo_LässerTimo_Lässer Member Posts: 481
    Try to use a shorter variable name.
    Instead of MSWordApp use WdApp or anything else what is short enough, so the events are unique.
    Timo Lässer
    Microsoft Dynamics NAV Developer since 1997
    MSDynamics.de - German Microsoft Dynamics Community - member of [clip]
  • jemmyjemmy Member Posts: 247
    Hello Timo, You hit to the point! :D
    I really don't suspect it will be caused by length of variable name.
    MSWordApp is 9 chars WdApp is 5 chars. A difference of 4 chars!
    I should be aware of these later...

    Thanks a lot. :D

    Jemmy
  • AngeloAngelo Member Posts: 180
    Hello Jimmy,

    Itu yang saya maksud. Bikin variable lain, jangan sama persis seperti di buku (file pdf). :D
  • ajhvdbajhvdb Member Posts: 672
    When I compile the object, it will give an error:
    The variable MSWORDAPP::MAILMERGEDATASOURCE is defined more than once.
    An Example could be: 'File' exists as both a data type and a global variable.


    Had the same problem in excel, thanks, making the var name shorter..., i never would have guessed it.
  • BeliasBelias Member Posts: 2,998
    yes, it's an old topic, but i found recently this issue in nav 5.0(and 4.03, I don't tested other versions): and it can't be solved with a shorter variable name. why?because there are two other longer triggers:

    -mailmergedatasourcevalidate
    -mailmergedatasourcevalidate2

    and, best of all, using a 1 character-long variable the name is not unique;
    the system recognise only 'mailmergedatasourcevalidate' but not the last "2", so the two triggers are the same...for only 1 char.......
    ](*,) ](*,) ](*,)
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • MalajloMalajlo Member Posts: 294
    Export object in txt and search for definitions of variable. It is common that you have one var defined as global and using same name in local vars.
  • BeliasBelias Member Posts: 2,998
    thanks Malajlo, but i have already checked this: try to create a new codeunit and create only one variable (automation, microsoft word, application)...the error persists...isn't there a way to declare a blank variable?? :mrgreen::mrgreen:
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • BeliasBelias Member Posts: 2,998
    ...ok...try to do this: create a new Codeunit, declare a global variable of type automation, Microsoft Word 12.0 Object Library, Application

    compile (error)

    cut the entire variable and paste the line in the locals.

    compile.........no error!!! :-k
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • hbinkhbink Member Posts: 5
    Hi,

    Problem is that <varname>::MailMergeDataSourceValidate2 must be 30 or less. Because "::MailMergeDataSourceValidate2" is 30 chars long, NAV is cut the name. If you have a varname with 1 char the event name is cut to W::MailMergeDataSourceValidate. This event already exists.

    If you want to use the Automation 'Microsoft Word 12.0 Object Library'.Application as a GLOBAL (without events) you can do it as follows.

    1) Define a short global var eg.: WA as an Automation 'Microsoft Word 12.0 Object Library'.Application (With Events = No)
    2) Save object without compiling
    3) Export object as text
    4) Edit text-file and change MailMergeDataSourceValidate2 to MailMergeDataSourceVal2 (or just delete the whole event-line).

    OLD:
    EVENT WA@1000000045::MailMergeDataSourceValidate2@30(Doc@1000000001 : Automation "{00020905-0000-0000-C000-000000000046} 8.4:{00020906-0000-0000-C000-000000000046}:'Microsoft Word 12.0 Object Library'.Document";VAR Handled@1000000000 : Boolean);
    BEGIN
    END;

    NEW:
    EVENT WA@1000000045::MailMergeDataSourceVal2@30(Doc@1000000001 : Automation "{00020905-0000-0000-C000-000000000046} 8.4:{00020906-0000-0000-C000-000000000046}:'Microsoft Word 12.0 Object Library'.Document";VAR Handled@1000000000 : Boolean);
    BEGIN
    END;

    5) Import the text and compile the object. \:D/

    This methode works as long as you don't use the events [-X ! If you are using the events the object is compiling but you get a runtime-error.

    Who has a solution for using 'Microsoft Word 12.0 Object Library'.Application as a global with events #-o ?
Sign In or Register to comment.