ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   how sendKeys to Acrobat Reader (https://www.excelbanter.com/excel-programming/280390-how-sendkeys-acrobat-reader.html)

Ian Elliott[_3_]

how sendKeys to Acrobat Reader
 
Thanks in advance.
I am writing a macro that starts Reader (from Excel), and
trying to get it to select the entire file. I am using
sendKeys, but with no luck. The code works, but sendKeys
doesn't select all. AppActivate does flash the Reader
button on the buttom of the screen for a second, so I
believe it successfully activates it. I am not sure what I
am doing wrong, but if anybody could help me I would
appreciate it-my code is:

Sub test()
x = Shell("C:\Program Files\Adobe\Acrobat 5.0
\Reader\AcroRd32.exe", vbNormalNoFocus)
channel = DDEInitiate("acroview", "control")
DDEExecute channel, "[DocOpen(""c:\pier.pdf"")]"
AppActivate (x)
Application.SendKeys "^a", True 'CTRL-A should select all
End Sub

I have tried with application.sendkeys "^A", using false
or true, neither with any luck, and the way I am executing
this is from the VB editor, hitting the run sub/user form
button on the tool bar (eventually this macro will be
executed by a button on the worksheet).

I think my problem is somewhere to do with the queing for
sendkeys.
If anyone has any ideas, would appreciate it.
Thanks again.


Tom Ogilvy

how sendKeys to Acrobat Reader
 
This worked for me:

Sub Tester2a()
Shell "C:\Program Files\Adobe\Acrobat 5.0\Reader\AcroRd32.exe" & _
" F:\Bus_route_16a-l.pdf", 1
' the following selects all through the menu
Application.SendKeys "%es", False
End Sub

--
Regards,
Tom Ogilvy

"Ian Elliott" wrote in message
...
Thanks in advance.
I am writing a macro that starts Reader (from Excel), and
trying to get it to select the entire file. I am using
sendKeys, but with no luck. The code works, but sendKeys
doesn't select all. AppActivate does flash the Reader
button on the buttom of the screen for a second, so I
believe it successfully activates it. I am not sure what I
am doing wrong, but if anybody could help me I would
appreciate it-my code is:

Sub test()
x = Shell("C:\Program Files\Adobe\Acrobat 5.0
\Reader\AcroRd32.exe", vbNormalNoFocus)
channel = DDEInitiate("acroview", "control")
DDEExecute channel, "[DocOpen(""c:\pier.pdf"")]"
AppActivate (x)
Application.SendKeys "^a", True 'CTRL-A should select all
End Sub

I have tried with application.sendkeys "^A", using false
or true, neither with any luck, and the way I am executing
this is from the VB editor, hitting the run sub/user form
button on the tool bar (eventually this macro will be
executed by a button on the worksheet).

I think my problem is somewhere to do with the queing for
sendkeys.
If anyone has any ideas, would appreciate it.
Thanks again.




Ian Elliott[_3_]

how sendKeys to Acrobat Reader
 
Hmm-I got it to work actually, with this code:
Sub test()
x = Shell("C:\Program Files\Adobe\Acrobat 5.0
\Reader\AcroRd32.exe", vbNormalNoFocus)
channel = DDEInitiate("acroview", "control")
DDEExecute channel, "[DocOpen(""c:\pier.pdf"")]"
AppActivate (x)
Application.SendKeys "^a", True
Application.SendKeys "^c", True
Dim wordapp As New Word.Application
With wordapp
.Visible = True
.Documents.Add DocumentType:=wdNewBlankDocument
.Selection.PasteAndFormat (wdPasteDefault)
End With
End Sub
"^A" doesn't work, but "^a" does.
Sorry for all the fuss.
Thanks.

-----Original Message-----
This worked for me:

Sub Tester2a()
Shell "C:\Program Files\Adobe\Acrobat 5.0

\Reader\AcroRd32.exe" & _
" F:\Bus_route_16a-l.pdf", 1
' the following selects all through the menu
Application.SendKeys "%es", False
End Sub

--
Regards,
Tom Ogilvy

"Ian Elliott" wrote

in message
...
Thanks in advance.
I am writing a macro that starts Reader (from Excel),

and
trying to get it to select the entire file. I am using
sendKeys, but with no luck. The code works, but sendKeys
doesn't select all. AppActivate does flash the Reader
button on the buttom of the screen for a second, so I
believe it successfully activates it. I am not sure

what I
am doing wrong, but if anybody could help me I would
appreciate it-my code is:

Sub test()
x = Shell("C:\Program Files\Adobe\Acrobat 5.0
\Reader\AcroRd32.exe", vbNormalNoFocus)
channel = DDEInitiate("acroview", "control")
DDEExecute channel, "[DocOpen(""c:\pier.pdf"")]"
AppActivate (x)
Application.SendKeys "^a", True 'CTRL-A should select

all
End Sub

I have tried with application.sendkeys "^A", using false
or true, neither with any luck, and the way I am

executing
this is from the VB editor, hitting the run sub/user

form
button on the tool bar (eventually this macro will be
executed by a button on the worksheet).

I think my problem is somewhere to do with the queing

for
sendkeys.
If anyone has any ideas, would appreciate it.
Thanks again.



.


keepITcool

how sendKeys to Acrobat Reader
 
opening the PDF can be done using by using follow hyperlink
it avoids the need for version & path specifications.

Sub AcroURLCopyPaste()
Dim sUrl$

ActiveSheet.Cells.ClearContents
ActiveSheet.Cells(1).Select
sUrl = "file:///" & c:\pier.pdf"
ActiveWorkbook.FollowHyperlink (sUrl)
Application.Wait Now + TimeSerial(0, 0, 2)
SendKeys "^a", True
SendKeys "^c", True
SendKeys "%{f4}"
ActiveSheet.Paste

End Sub


keepITcool

< email : keepitcool chello nl (with @ and .)
< homepage: http://members.chello.nl/keepitcool


"Ian Elliott" wrote:

Hmm-I got it to work actually, with this code:
Sub test()
x = Shell("C:\Program Files\Adobe\Acrobat 5.0
\Reader\AcroRd32.exe", vbNormalNoFocus)
channel = DDEInitiate("acroview", "control")
DDEExecute channel, "[DocOpen(""c:\pier.pdf"")]"
AppActivate (x)
Application.SendKeys "^a", True
Application.SendKeys "^c", True
Dim wordapp As New Word.Application
With wordapp
.Visible = True
.Documents.Add DocumentType:=wdNewBlankDocument
.Selection.PasteAndFormat (wdPasteDefault)
End With
End Sub
"^A" doesn't work, but "^a" does.
Sorry for all the fuss.
Thanks.




All times are GMT +1. The time now is 02:03 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com