Sendkeys to Adobe Reader?

I

Ian Elliott

Thanks in advance.
I am having a problem using SendKeys with Adobe Reader.
I want to open Adobe Reader with a file already in the
command line (using shell) and then sendkeys to it to
highlight (CTRL-A) the file, copy it (CTRL-C), then quit
(CTRL-Q) (but I am having little luck). Then I plan to
open Word and paste into another file (which I will worry
about later).

I have tried this:
Dim testvar as variant
testvar = Shell("C:\Program Files\Adobe\Acrobat 5.0
\Reader\acrord32.exe c:\pier.pdf", vbNormalNoFocus)
AppActivate testvar, False
DoEvents

SendKeys "^(a)", True 'this is CTRL+A
SendKeys "^a", False 'this is CTRL, then A (I think). I am
'not sure how true or false changes this.

But what happens is:
I have the VBE in a window. Upon executing shell (F8, line
by line), the Reader header opens, then the Reader window
opens (with the file pier.pdf), but the part over the VBE
then goes "underneath"
the VBE window (the other part is still displayed).
Upon AppActivate, the Reader window that was hidden
surfaces for a moment then goes back under the VBE.
DoEvents doesn't show anything on the screen.
Nothing visible for the sendkeys either.
I think SendKeys is sending to the VBE (since if I change
to ^(m) it opens the import file dialog box, obviously a
VBE function. What am I doing wrong here? How do I get it
to send to the application?
All help greatly appreciated.
 
J

jaf

Hi Ian,
This works.

Sub testpdf()
Dim testvar
testvar = Shell("C:\Program Files\Adobe\Acrobat 5.0\Reader\acrord32.exe
c:\test.pdf", vbNormalNoFocus)
DoEvents
AppActivate "acrobat reader", False
DoEvents
SendKeys "^a"
MsgBox "sent ctl a"
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