Automation: MS Word - duplicate variable

Hi, I was trying to make a simple function which handles Word documents and I’m experiencing a strange behaviour. In a native 3.70a database I have a form with the followiong global variables: Name DataType Subtype Length MSWordApp Automation 'Microsoft Word 11.0 Object Library'.Application MSWordDoc Automation 'Microsoft Word 11.0 Object Library'.Document MSWordDocs Automation 'Microsoft Word 11.0 Object Library'.Documents MSWordRange Automation 'Microsoft Word 11.0 Object Library'.Range Nothing else so far, just the variables. If I press F11 I get the following 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” Uh? [?] Actually, if I set the WithEvents property of the “application” variable to yes the MSWordApp::MailMergeDataSource trigger appears twice in the editor sheet, but I can do nothing about it. I’m working under XP. I’m quite new to this kind of things and I was just trying to replicate the example in the manual, following sheepily the istructions. Anybody has an idea of what I’m doing wrong? I have none. [:(] Anna

Hi Anna, This is because the variable length is limited to 30 char. in Navision and Word’s function MSWORDAPP::MAILMERGEDATASOURCE is 30 char actually there are probably two word functions like MSWORDAPP::MAILMERGEDATASOURCEstop and MSWORDAPP::MAILMERGEDATASOURCEstart Navision only grabs the first 30 chars so they look identical and hence the conflict sadly this is where my helpfulness ends I thought they had fixed this in some version but I don’t know which one. At least you’re not doing anything wrong Steve

…and there are (at least) two ways to fix it: 1) If you don’t really need to respond to events from the object, clear the ‘WithEvents’ property; or 2) Shorten the variable name, in hopes that when the event names are appended (along with the two colons), the result will be less than 30 characters…

quote:

…and there are (at least) two ways to fix it: 1) If you don’t really need to respond to events from the object, clear the ‘WithEvents’ property; or 2) Shorten the variable name, in hopes that when the event names are appended (along with the two colons), the result will be less than 30 characters…
Originally posted by fbrande - 2005 May 04 : 23:23:21

Shortening the variable name did work… silly Navision! [:P] Thank you Anna

Hi, I’ve tested on 3.70b and just deleted 1 letter and it works. Name DataType Subtype Length MSWordAp Automation ‘Microsoft Word 11.0 Object Library’.Application MSWordDoc Automation ‘Microsoft Word 11.0 Object Library’.Document MSWordDocs Automation ‘Microsoft Word 11.0 Object Library’.Documents MSWordRange Automation ‘Microsoft Word 11.0 Object Library’.Range [Yeah!]