Search code examples
excelvbaui-automationmicrosoft-ui-automation

How to manipulate a window which is in Off Screen status by UI Automation


I click on the "save" button from a window named 'Main', then a new window named 'Save As ..' will pop up. But actually, that 'Main' window is always in minimized status and its IsOffscreen property is True showed in Tool UISPY, so when it is minimized, the 'Save As ..' window will never pop up, is there some methods to continue my procedure with the 'main' window minimized? Thank you!


Solution

  • There are two separate VBA commands - one for popping up the "Save As" window, one for doing the actual save. If this is the work book you're saving, there's

    Application.GetSaveAsFilename - pops up the Save As dialogue and returns the file name Workbook.SaveAs - method to do the actual save.

    So you need code that separates the two statements, and detects whether your "main" window is minimized or not before even showing the Save As dialogue.