Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

VBScript: AppActivate / Restore Window not working

Hi All,

I'm trying to restore a window that has been minimised but I can't get the VBScript working?

This should work:

sub restore

Set WshShell = WScript.CreateObject("WScript.Shell")

WshShell.AppActivate "Untitled - Notepad"

success = WshShell.appactivate("Untitled - Notepad")

if success then WshShell.sendkeys "% r"

end sub

Any ideas, to where I've gone wrong?

7 Replies
tamilarasu
Champion
Champion

Jammy,

Try this,


Sub restore

Set WshShell = CreateObject("WScript.Shell")   

WshShell.AppActivate "Untitled - Notepad" 

success = WshShell.appactivate("Untitled - Notepad") 

if success then WshShell.sendkeys "% r"

End Sub

Not applicable
Author

Tried but unfortunately it still doesn't restore the minimised program?

vikramv
Creator III
Creator III

rem **Can you try this**

set c=ActiveDocument.GetSheetObject("YourObjectID")

if c.IsMaximized then

    c.Restore

else

    c.Maximize

end if

Not applicable
Author

This didn't work either

vikramv
Creator III
Creator III

Can you show a screenshot of what kind of object you want to minimize ?

If trying to restore objects when navigating from one sheet to other.....This would make all minimized object to maximize in active sheet object, if any...

Sub maxi

set s = ActiveDocument.ActiveSheet.SheetObjects(0).GetSheet

for i=0 to s.NoOfSheetObjects-1

    s.SheetObjects(i).restore

next

end sub

Not applicable
Author

After a macro is run, for some reason Qlikview gets confused & brings the last active window to the front.

For example... I open a QV file from explorer -> run the macro in QV -> explorer is brought to the font.

If explorer is minimised, this doesn't happen.  So I need a script which restores QV to the front.

I have this working:

Sub open

dim objSHL

set objSHL = createobject("wscript.shell")

objSHL.AppActivate "Notepad"

objSHL.sendkeys "(% )(R)"

End Sub

So this will restore Notepad to the front.

But now the next question..... how to restore the current QV project to the front?

I've substituted "Notepad" with... "QliKView", "QlikView x64........ " all combinations but it doesn't restore QV to the front!?

Any more ideas, as it's driving me crazy?

marcus_sommer

In my experience it should be last way to solve a task with activating/restoring windows and sending shortcuts per any script - it won't never run really stable. Therefore what is your real aim? Maybe there are other ways to get your wanted results.

- Marcus