Reputation: 7
Part of my code is: Set objShell = CreateObject("WScript.Shell") objShell.AppActivate("Book1 - Excel") Now i have opened afew applications in desktop and when Excel is behind others this part makes its window active. But if i minimize excel and run this part, it does not restore it. Any ideas?
Upvotes: 0
Views: 1615
Reputation: 200443
Drop that approach altogether. SendKeys
is a very, very poor way of automating things and should not be used at all. If you need to automate MS Office applications use the respective COM object:
Set xl = CreateObject("Excel.Application")
xl.Visible = True
Set wb = xl.Workbooks.Add
...
wb.Close
xl.Quit
Upvotes: 1
Reputation: 15400
Try this. It works fine for me.
Set objShell = CreateObject("WScript.Shell")
objShell.AppActivate("Book1 - Excel")
WScript.Sleep 500 'sleep is required here to make this work
objShell.SendKeys "% x" ' to maximize
Upvotes: 0