Micro Focus QTP (UFT) Forums
Find Word, Excel or PPT Windows and manage them - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: VB Scripting/Descriptive Programming (https://www.learnqtp.com/forums/Forum-VB-Scripting-Descriptive-Programming)
+--- Thread: Find Word, Excel or PPT Windows and manage them (/Thread-Find-Word-Excel-or-PPT-Windows-and-manage-them)



Find Word, Excel or PPT Windows and manage them - desti77 - 11-17-2010

Hi folks,

i want to check if i have an open Excel/Word/Powerpoint Window on my Desktop. When i ll find one i want to manage it e.g. save the document. I got three objects in my repository and if my script will find the window, i want to manage it by referencing the object from my repository to my objOfficeApp variable:
My approach for finding the windows works. Here my script:


Code:
[font=Courier]If Window("regexpwndclass:=OpusApp").Exist  Then
        Set objOfficeApp = Window("Microsoft Word")
        Exit function
    end if

    If Window("regexpwndclass:=PP10FrameClass").Exist  Then
        set objOfficeApp = Window("Microsoft PowerPoint")
        Exit function
    End If

    If Window("regexpwndclass:=XLMAIN").Exist  Then
        set objOfficeApp = Window("Microsoft Excel")
        Exit function
    End If[/font]

[font=Arial]And now i want to manage the window:[/font]

[font=Courier]objOfficeApp.Activate
...[/font]

But that doesnt work. I think i make a mistake in referencing my found object window with my variable.
Do u have any advice for me to solve my issue?
Important: My Testcases can open one of these Applications (e.g. Excel, Word, PPT) and i want to find (that works) and manage the window! Is there another (maybe better) approach?

Thanks in advance
Stefan Smile


RE: Find Word, Excel or PPT Windows and manage them - Saket - 11-18-2010

Use descriptive programming while you set your object for the documents. there could be difference in properties in OR and the document opened.