How can I solve this MSAA error?

Hello
I'm fairly new to Coded UI so please cut me some slack.
What I'm trying to do is just something very simple. Taking a screenshot of MS Excel.
Here are my steps to reproduce:
Pre-requisite: Have Excel 2010 Open
Steps:
Begin Recording
1. Hover your mouse to the top left corner and click the tiny down-arrow
2. Select "Print Preview and Print"
3. Go to File Menu
4. Click EXIT
Stop Recording
-------------------------------------------------------------------Code------------------------------------------------------------------------------
namespace excelscreenshot{    /// <summary>    /// Summary description for CodedUITest1    /// </summary>    [CodedUITest]    public class CodedUITest1    {        public CodedUITest1()        {        }        [TestMethod]        public void CodedUITestMethod1()        {            // To generate code for this test, select "Generate Code for Coded UI Test" from the shortcut menu and select one of the menu items.            // For more information on generated code, see http://go.microsoft.com/fwlink/?LinkId=179463            this.UIMap.email();            //WinMenuItem uIPrintPreviewandPrintMenuItem = this.UIMicrosoftExcelBook1Window.UIItemWindow.UICustomizeToolbarClient.UICustomizeQuickAccessGroup.UIPrintPreviewandPrintMenuItem;            Image pic = this.UIMap.UIMicrosoftExcelBook1Window.CaptureImage();            pic.Save(@"C:\Users\Diego Cortes\Desktop\derecho\foto.jpg"); //,System.Drawing.Imaging.ImageFormat.Jpeg);            TestContext.AddResultFile(@"C:\Users\Diego Cortes\Desktop\derecho\foto.jpg");        }        #region Additional test attributes        // You can use the following additional attributes as you write your tests:        ////Use TestInitialize to run code before running each test         //[TestInitialize()]        //public void MyTestInitialize()        //{                //    // To generate code for this test, select "Generate Code for Coded UI Test" from the shortcut menu and select one of the menu items.        //    // For more information on generated code, see http://go.microsoft.com/fwlink/?LinkId=179463        //}        ////Use TestCleanup to run code after each test has run        //[TestCleanup()]        //public void MyTestCleanup()        //{                //    // To generate code for this test, select "Generate Code for Coded UI Test" from the shortcut menu and select one of the menu items.        //    // For more information on generated code, see http://go.microsoft.com/fwlink/?LinkId=179463        //}        #endregion        /// <summary>        ///Gets or sets the test context which provides        ///information about and functionality for the current test run.        ///</summary>        public TestContext TestContext        {            get            {                return testContextInstance;            }            set            {                testContextInstance = value;            }        }        private TestContext testContextInstance;        public UIMap UIMap        {            get            {                if ((this.map == null))                {                    this.map = new UIMap();                }                return this.map;            }        }        private UIMap map;    }}
----------------------------------------------------------------------This is the Error--------------------------------------------------------
Microsoft.VisualStudio.TestTools.UITest.Extension.UITestControlNotAvailableException was unhandled by user code
  HResult=-268111872
  Message=The control is not available or not valid. Additional Details:
TechnologyName:  'MSAA'
Name:  'Print Preview and Print'
ControlType:  'MenuItem'
  Source=Microsoft.VisualStudio.TestTools.UITesting
  BasicMessage=The control is not available or not valid.
  StackTrace:
       at Microsoft.VisualStudio.TestTools.UITesting.UITestControl.EnsureValid(Boolean waitForReady, Boolean refetch)
       at Microsoft.VisualStudio.TestTools.UITesting.UITestControl.GetPropertyValue(String propertyName)
       at Microsoft.VisualStudio.TestTools.UITesting.UITestControl.GetProperty(String propertyName)
       at Microsoft.VisualStudio.TestTools.UITesting.UITestControl.GetPropertyInternal[T](String propertyName)
       at Microsoft.VisualStudio.TestTools.UITesting.UITestControl.get_BoundingRectangle()
       at Microsoft.VisualStudio.TestTools.UITesting.UITestControl.CaptureImage()
       at excelscreenshot.CodedUITest1.CodedUITestMethod1() in C:\Users\Diego Cortes\Documents\Visual Studio 2010\Projects\excelscreenshot\excelscreenshot\CodedUITest1.cs:line 32
  InnerException: Microsoft.VisualStudio.TestTools.UITest.Extension.UITestControlNotAvailableException
       HResult=-268111872
       Message=The control is not available or not valid. Additional Details:
TechnologyName:  'MSAA'
ControlType:  'Window'
       Source=Microsoft.VisualStudio.TestTools.UITesting
       BasicMessage=The control is not available or not valid.
       StackTrace:
            at Microsoft.VisualStudio.TestTools.UITesting.UITestControl.EnsureValid(Boolean waitForReady, Boolean refetch)
            at Microsoft.VisualStudio.TestTools.UITesting.UITestControl.EnsureValid(Boolean waitForReady)
            at Microsoft.VisualStudio.TestTools.UITesting.UITestControl.EnsureValid()
            at Microsoft.VisualStudio.TestTools.UITesting.UITestControl.FindFirstDescendant(String queryId, Int32 maxDepth, Int32& timeLeft)
            at Microsoft.VisualStudio.TestTools.UITesting.UITestControl.FindFirstDescendant(String queryId)
            at Microsoft.VisualStudio.TestTools.UITesting.UITestControl.EnsureValid(Boolean waitForReady, Boolean refetch)
       InnerException: System.Runtime.InteropServices.COMException
            HResult=-2147467259
            Message=Error HRESULT E_FAIL has been returned from a call to a COM component.
            Source=Microsoft.VisualStudio.TestTools.UITest.Playback
            ErrorCode=-2147467259
            StackTrace:
                 at Microsoft.VisualStudio.TestTools.UITest.Playback.Engine.IRPFPlayback.FindAllScreenElements(IScreenElement pScreenElementStart, String bstrQueryId, Object&
pvarResKeys, Int32 cResKeys, Int32 nMaxDepth, Object[]& foundDescendants)
                 at Microsoft.VisualStudio.TestTools.UITest.Playback.ScreenElement.FindTopLevelWindowHelper(String queryId)
                 at Microsoft.VisualStudio.TestTools.UITest.Playback.ScreenElement.FindFromPartialQueryId(String queryId)
                 at Microsoft.VisualStudio.TestTools.UITesting.UITestControl.EnsureValid(Boolean waitForReady, Boolean refetch)
            InnerException:
THANKS
for your help
DIEGO

Hi DIEGO,
As far as I know, the coded UI test has a limitation for office client app controls.
Reference:
https://msdn.microsoft.com/en-us/library/dd380742(v=vs.120).aspx
Best Regards,
Jack 
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.

Similar Messages

Maybe you are looking for

  • LINUX:while Deleting OLD backup's got error that ORACLE is not in DBA group

    Error Error - The specified host user is not a member of the operating system DBA group. The host user must be a DBA group member since the database user does not have the SYSDBA role. But. put users: system,oracle in OS /etc/group : oracle:x:500:ora

  • Restoring the phone possibly?

    I've been reading about battery problems, and that restoring your iPhone should help with these problems (for some reason). Well, I think my iPhone 3GS is one of those phones affected by these problems of short battery life. The battery went down fro

  • IDVD Freezes when creating new project!?

    Hi all, When I open iDVD, it give me the main screen, I click Create New Project. The window comes up, but it has trouble opening the stuff inside the window, and does the dreaded rainbow ball.. Never comes out of it. I have to force quit it to get o

  • SIDADM PASSWORD Incorrect

    Hi all, i have this problem on my EHPI, 1st my system is not installed as distirbuted.. its (CI+DB) and a DI on other server. im using aix # oslevel -s 6100-04-01-0944 I have found note Note 1140980 - sapstartsrv user authentication on AIX , using la

  • Video conversion problem: no sound

    Hi, when I convert a video for iPhone / iPod touch, there is no sound in the end. Same with iTunes. What - except re-install both, which I have done already - can I do? Thanks a lot Peter