P
Patricia Shannon
I am printing a bunch of documents containing screen prints of mainframe
screens, which have a black background. We did not want to print these as is
because it would use too many toner cartridges. I found I can copy the
picture into Paint, invert the colors, and copy back to Word.
Since I will be doing so many, I wrote a VBA macro for Word, which uses
Sendkeys to execute the needed actions in Paint. But it took longer to write
the macro than I expected, although not so long as to be a waste of time.
The problem is that I can't send the shortcut keys (eg., Ctrl+A, Ctrl+V)
that I would normally use when operating directly in Paint. They had no
effect. I was able to do what I wanted by using the menu commands (eg.,
Alt+EA, Alt+EP).
Also, I had to use more than one Sendkeys, because commands after the paste
did not execute.
I am including the macro I got to work (which includes comments to myself
about things that didn't work).
I'm wondering if my problems are specific to Paint, or are more general?
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
'
' ---- Word commands ---
Selection.Copy ' copy selected picture
' --- run Paint
AppActivate "untitled - Paint"
''' Note: Sendkeys Ctrl-codes (eg. "^A") do not work with Paint
''' Note: When all commands sent to Paint in one SendKeys,
''' 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
SendKeys "%EA%EP", True
AppActivate "untitled - Paint"
SendKeys "%II%EC%{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
End Sub
screens, which have a black background. We did not want to print these as is
because it would use too many toner cartridges. I found I can copy the
picture into Paint, invert the colors, and copy back to Word.
Since I will be doing so many, I wrote a VBA macro for Word, which uses
Sendkeys to execute the needed actions in Paint. But it took longer to write
the macro than I expected, although not so long as to be a waste of time.
The problem is that I can't send the shortcut keys (eg., Ctrl+A, Ctrl+V)
that I would normally use when operating directly in Paint. They had no
effect. I was able to do what I wanted by using the menu commands (eg.,
Alt+EA, Alt+EP).
Also, I had to use more than one Sendkeys, because commands after the paste
did not execute.
I am including the macro I got to work (which includes comments to myself
about things that didn't work).
I'm wondering if my problems are specific to Paint, or are more general?
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
'
' ---- Word commands ---
Selection.Copy ' copy selected picture
' --- run Paint
AppActivate "untitled - Paint"
''' Note: Sendkeys Ctrl-codes (eg. "^A") do not work with Paint
''' Note: When all commands sent to Paint in one SendKeys,
''' 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
SendKeys "%EA%EP", True
AppActivate "untitled - Paint"
SendKeys "%II%EC%{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
End Sub