none
Document Title for Automation RRS feed

  • Question

  • Hello,

    we use the following code to find window handle

        FWordApp                := CreateOleObject('Word.Application');
        FConnected              := True;
        FWordApp.Visible        := False;
        FADoc  := FWordApp.Documents.Add(EmptyParam, False);
        sName := FADoc.Name + ' - ' + FWordApp.Name;
        FHandle := FindWindow(MSWordWndClass, PChar(sName));

    This works for Word 2003 where sName is "Document1 - Microsoft Word" and coinsides with the document window title.

    However, this does not work for Word 2013 where the title is "Document1 - Word" and sName is the same as above. Is there some other property that allows to find the correct title of the document window?

    Thanks,

    Vladimir 


    Vladimir Belitski

    Wednesday, October 15, 2014 9:15 AM

Answers

All replies

  • I seem to recall that a change was made to the active window name. You might consider checking the value of Application.Version and if it is 15.0 then dynamically adjust your "FHandle" value.

    Hope this helps


    Kind Regards, Rich ... http://greatcirclelearning.com

    Wednesday, October 15, 2014 12:48 PM
  • Thank You very much. This is what I actually already tried. It works. But I would prefer to find the string 

    "Document1 - Word" 

    as combination of some Word parameters, like for version 11, when it is 

    FADoc.Name + ' - ' + FWordApp.Name

    The problem is that in Word Version 15 the Name property is still "Microsoft Word" (not just "Word")


    Vladimir Belitski

    Wednesday, October 15, 2014 1:11 PM
  • Hi,

    As far as I know, from Office 2007 (version 12.0), the name of Word application has been "Microsoft Word" instead of "Word". In addition, support for Office 2003 (version 11.0) ended on April 8, 2014.

    I'm afraid Name property of Application object in Word Object Model will be always "Microsoft Word" and we cannot change that.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, October 21, 2014 9:31 AM
    Moderator
  • Hi,

    but this would mean, there is no way to find the title of the document (created via Word Automation) using parameters available from the Automation Object. Is it really so? 


    Vladimir Belitski

    Tuesday, October 21, 2014 9:45 AM
  • Hi,

    In fact, the Caption property of the Application object is "Word", so I think we can use this property to find the matched window instead of Name property.



    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, October 21, 2014 10:01 AM
    Moderator
  • FWordApp.Caption ?


    Peter Jamieson

    Tuesday, October 21, 2014 10:47 AM