Forum Discussion

jlegan's avatar
jlegan
New Contributor
15 years ago

Office 2010 Interaction / Automation

I have written a rather extensive framework for testing applications (ODT based, abstracted classes, etc...) and am in the process of incorporation Office 2010 into the framework. The vast majority of the operations in the application have not changed since Office 2007 (most are hotkey based), but I have run into some trouble interacting with the print dialog box of any Office 2010 app.



What appears to be happening is that the ComboBox that you use to select your printer:




Sys.Process("WINWORD").Form("test.docx -").Window("FullpageUIHost").Window("NetUIHWND").Pane("Backstage view").Client(0).Pane("Print").Grouping("Print").Grouping(0).Client(0).ComboBox("Which Printer")



Is implemented differently than the actual list of items in the ComboBox. Below is what I get when I use the object browser on an individual combobox item:



Sys.Process("WINWORD").Window("Net UI Tool Window", "", 1).Panel("Which Printer").List("Which Printer").Client(0).ListItem("My Printer")



The problem is that for the life of me I cannot get ClickItem() on the combobox to actually change the selection, either by name or index. I have tried MSAA both in the new mode and in the legacy mode but to no avail. I have tried giving focus to the combobox, calling click() on it first to open it, etc... but nothing I do actually allows me to intelligently change the box. I am theorizing that I could probably open it and then walk each item looking for the string I want to select, but this is a really kludge solution.



Can anyone shed some light on this dilema?



Thanks,



Jim


.Process("WINWORD").Form("test.docx -").Window("FullpageUIHost").Window("NetUIHWND").Pane("Backstage view").Client(0).Pane("Print").Grouping("Print").Grouping(0).Client(0).ComboBox("Which Printer")Is implemented differently than the actual list of items in the ComboBox. Below is what I get when I use the object browser on an individual combobox item:.Process("WINWORD").Window("Net UI Tool Window", "", 1).Panel("Which Printer").List("Which Printer").Client(0).ListItem("My Printer")The problem is that for the life of me I cannot get ClickItem() on the combobox to actually change the selection, either by name or index. I have tried MSAA both in the new mode and in the legacy mode but to no avail. I have tried giving focus to the combobox, calling click() on it first to open it, etc... but nothing I do actually allows me to intelligently change the box. I am theorizing that I could probably open it and then walk each item looking for the string I want to select, but this is a really kludge solution.Can anyone shed some light on this dilema?Thanks,Jim

1 Reply


  • Hi James,





    We were able to reproduce this behavior, and we will investigate it. In the meantime, you can use the below script to accomplish your task:







    function ClickItemMain()

    {

      var wComboBox = Sys.Process("WINWORD").Form("Document1 -").Window("FullpageUIHost").Window("NetUIHWND").Pane("Backstage view").Client(0).Pane("Print").Grouping("Print").Grouping(0).Client(0).ComboBox("Which Printer");

      var strItem = "Microsoft XPS Document Writer";

      if (ClickItem(wComboBox, strItem))

      {

        Log.Message("The '" + strItem + "' combo-box item was successfully clicked.");

      }

    }





    function ClickItem(wCombo, strItem)

    {

      Log.LockEvents(1);

      //Open dropdown

      wCombo.Button("Open").Click();

      var p = getProcess(wCombo);

      //Get dropdown

      var wDropdown = p.Window("Net UI Tool Window", "", 1).Panel("Which Printer").List("Which Printer").Client(0);

      var wlistItem = wDropdown.FindChild("Caption", strItem)

      if (wlistItem.Exists)

      {

        //Click item

        wlistItem.Click();

        Log.UnLockEvents();

        Log.Event("The '" + strItem + "' combo-box item was clicked.");

        return true;  

      }

      else

      {

        Log.UnLockEvents();

        Log.Error("The '" + strItem + "' combo-box item was not found.");

        return false;

      }

    }





    function getProcess(obj)

    {

      while (!IsSupported(obj, "ProcessName"))

      {

        obj = obj.Parent;

      }

      return obj;

    }