Word - Documentname

I use automation to open MS-Word either with an existing Document or with an unnamed, empty document. The user makes his changes and saves the document under a new name using the Save As function in Word. Then the user closes MS-Word. How can i get the new name of the document to save it in a table?

What about … MyFilaname := wdDocument.Name … this should work. I didn’t try Marcus Marcus Fabian phone: +41 79 4397872 m.fabian@thenet.ch

Thanks for your answer, Fabian. But this doesn’t work. If the User saves his changes under a new filename you don’t get this filename with wdDocument.Name. I use the following code: wdapp:Automation ‘Microsoft Word 8.0 Object Library’.Application wddoc:Automation ‘Microsoft Word 8.0 Object Library’.Document CLEAR(wdapp); CLEAR(wddoc); IF NOT CREATE(wdapp) THEN Error… IF EXISTS() THEN wddoc := wdapp.Documents.open() ELSE wddoc := wdapp.Documents.Add; wdapp.Visible := TRUE; wdapp.Activate; … MESSAGE(‘Filename: %1’, wddoc.Name); … The Message only displays the old filename! A second try looks like this: wdapp:Automation ‘Microsoft Word 8.0 Object Library’.Application wddoc:Automation ‘Microsoft Word 8.0 Object Library’.Document tasks:Automation ‘Microsoft Word 8.0 Object Library’.Tasks CLEAR(wdapp); CLEAR(wddoc); CLEAR(tasks); IF NOT CREATE(wdapp) THEN Error… IF EXISTS() THEN wddoc := wdapp.Documents.open() ELSE wddoc := wdapp.Documents.Add; tasks := wdapp.tasks; wdapp.Visible := TRUE; wdapp.Activate; WHILE tasks.Exists(‘Microsoft Word’) DO Tempname := wddoc.Name; MESSAGE(‘Filename: %1’, Tempname); But this gives an error after closing Word: ‘unknown wddoc.Name’ The loop is repeated until the User open the SaveAs-Dialog. Then the code stops until word is closed completely! But after this the error occurs. The variables are cleared right after closing Word? Is there another way to solve my problem? Greetings Frank