SendKeys sends keystrokes to another program. So you have to be able to do
what you want using only the keyboard. Eg., Ctrl+V to paste
This a Word macro, but most of it is not specific to Word.
Before I run it, I select a picture.
The macro copies the picture, goes to the Paint program (which doesn't have
VBA), which is already open (it could be opened programmatically, if desired).
It uses SendKeys to
select everything already in Paint and delete it,
copy the picture from the clipboard to Paint
Tell Paint to invert the colors
copy the new picture from Paint to the clipboard
replace the picture in Word with the new picture from the clipboard
As you can see from the comment, I wasn't able to do everything in Paint
with a single SendKeys, for some reason. Maybe timing? So you might have to
play around to get it working right.
good luck
Sub InvertColors()
'
' InvertColors Macro
' Macro recorded 7/11/2006 by Patricia Shannon
' Invert colors of a picture, using Paint program
' Picture must be selected before macro is run
' At end of macro, the macro selects the next picture.
' Recommend turning off collection of multiple copied items into Clipboard
' to avoid problem with Paint when Clipboard is full :
' In Clipboard, turn off all options.
' If Paint gets hung up, in Word, open clipboard, clear clipboard, close
clipboard.
'
'
' ---- Word commands ---
Selection.Copy ' copy selected picture
' --- run Paint
AppActivate "untitled - Paint"
''' Note: Sendkeys Ctrl-codes (eg. "^A") do not work with Paint
''' SendKeys "%EA%EP%II%EC%{TAB}", True
''' actions ended after paste (%EP)
''' SendKeys "^A^V^C%{TAB}", True ' Ctrl-A Ctrl-V Ctrl-C return to
this application
''' Note: Commands after paste (%EP) were ignored, therefore multiple
''' SendKeys were needed
SendKeys "%EA%EP", True
AppActivate "untitled - Paint"
'''SendKeys "%II%EC%{TAB}", True
SendKeys "%II%ET%{TAB}", True
' ---- Word commands ---
Selection.Delete Unit:=wdCharacter, Count:=1 ' delete old picture
Selection.Paste ' copied converted picture
Selection.MoveLeft Unit:=wdWord, Count:=1 ' scroll left
SelectNextGraphic
ClearClipboard
End Sub