AppActivate statement acts erratically

poolhall

Active Member
Joined
Jan 9, 2009
Messages
350
I use Excel 2007 and Vista 64bit, if it matters.

When I use AppActivate statement, it acts erratically. For some applications it doesn't work at all, for some it works in 60% of the time, and for others it works perfectly.

For example, I have this code which saves a screenshot as an image:

Code:
Sub GetRating()
Dim RetVal
    With Sheets("Rating")
        .Columns("B:M").EntireColumn.AutoFit
        .Range("A1:N32").Copy
    End With
'RetVal = Shell("C:\Windows\system32\mspaint.exe", vbMaximizedFocus)
RetVal = Shell("C:\Program Files (x86)\IrfanView\i_view32.exe", 1)
'AppActivate "Untitled - Paint" '<--- this doesn't work
AppActivate "IrfanView" '<---- this works perfectly
Application.SendKeys ("^v"), True
Application.SendKeys ("s"), True
Application.SendKeys ("C:\Users\AccountName\Documents\Totalizator\" & ThisWorkbook.Name), True
Application.SendKeys ("~")
End Sub
So, AppActivate "IrfanView" works fine at all times. AppActivate "Paint" doesn't want to work at all whatever I do, e.g. change "Paint" for "Untitled - Paint", "mspaint", AppActivate RetVal, AppActivate Application.Caption, nothing works!

And I have another piece of code where I use AppActivate "FireFox" statements, and this works from about 50 to 60% of the time.

This really drives me crazy. :mad: Do you have any suggestion?
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
as appactivate works with the window title which can be changed in many instances it might be safer /more reliable, to use the findwindow API
 
Upvote 0

Forum statistics

Threads
1,196,503
Messages
6,015,577
Members
441,902
Latest member
alhaste

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top