SendKeys on Vista

neveu

Board Regular
Joined
Jan 27, 2009
Messages
225
hello forum,

i've made an VBA tool that would take the printscreen of the previous active window and copy it into Excel using Sendkeys

the program is running perfect on XP but fails big time on Vista.
do you know if there is anything specific with Vista that would have an effect on the Sendkey method?

any tips or information is greatly appreciated.
here is the code:

Uploaded with ImageShack.us

Code:
Sub all_print_screens()
Call a  'moves to the previous window
Call B  'print screen previous window
Call D  'goes back to last excel file opened
Call E  ''copy current print screen in the first row after the previous print screen
'Call f  'inserts the username, time stamp and default values & dropdown lists
End Sub

Sub a()
'moves to the previous window
'ALT+Tab - cauta pe net SENDKeys
Application.SendKeys "%{TAB}", True
DoEvents
Application.Wait (Now + 0.000005)

End Sub

Sub B()
'print screen previous window

'Application.SendKeys "{PRTSC}"
Application.SendKeys "(%{1068})", True ' printscreen
DoEvents
Application.Wait (Now + 0.000001)
DoEvents
End Sub
 
Sub c()
'move to Excel tool
'ALT+Tab - cauta pe net SENDKeys
'Application.SendKeys "{%TAB}"

End Sub

Sub D()
'goes back to last excel file opened ; [here will be the Excel file containing the macro
'AppActivate "Microsoft Excel"
'AppActivate Application.Caption
Application.SendKeys "%{TAB}"
DoEvents
Application.Wait (Now + 0.000001)

End Sub
Sub E()
'copy current print screen in the first row after the previous print screen
'Sub Find_Image_Range_In_Excel()
Dim rCount As Long
Dim shp As Shape
For Each shp In ActiveWorkbook.Worksheets(1).Shapes
 If shp.BottomRightCell.Row > rCount Then rCount = shp.BottomRightCell.Row
On Error Resume Next
Next
Sheets(1).Activate
   Cells(rCount + 7, 1).Select
       ActiveSheet.Paste
 
end sub
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
Are all the subs posted not working or is only one of them not working?
What version of excel are you using? (I'm guessing 2003) while Vista guys are using XL 2007?
 
Upvote 0
hi,
the program is working perfectly on XP - meaning it takes the right printscreen and copies it into excel and then Excel remains the active window

in vista, it takes some weird print screen (as inserted in the email) and the active window remains the one for which i wanted to take the printscreen.

just to give you more insight on the program:

what it does (XP) : selects the previous activated window; makes a printscreen, moves back to excel, copies the print screen.

i;m using excel 2007.


any thoughts on this?
 
Upvote 0

Forum statistics

Threads
1,214,924
Messages
6,122,294
Members
449,077
Latest member
Rkmenon

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