Open non MS applications

F

Frankie

I would like to open a non MS application in running my Macro.
I just want to copy and paste a range per my spreadsheet to the editor of
that application.
How can I choose "select all" and paste the whole range in order to
overwrite all existing data in that application ? If positive, is it
possible to execute some basic commands keys (like save file ...etc) in that
application ?
 
F

Frankie

Hi,

I opened the app. using Shell commands but I don't know how to execute
simple command like select all & paste. I try sendkeys command but it works
within excel only. Shall be pleased if you can give some clues.

Rgds,
 
F

Frankie

Hi,

I tried to use sendkeys commands but it only applies in office 2000 or
previous versions. Can you pls advise how I shall change the Sendkeys
commands in order to make them work in office 2003 ?

Thanks.

Rgds,
 
P

Patricia Shannon

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top