PDA

View Full Version : Copying from a PDF file



mdmackillop
10-14-2009, 10:28 AM
I have two codes, the first works, but produces a warning I can't find a way to eliminate.
The second gives no warning, but instead of copying the pdf contents, it copies the Sendkeys code and pastes it into my document.

The Send Keys code sends
Edit/Select All
Edit/Copy
Close

Any thoughts?


Sub OpenPDF(init As Range)
ActiveWorkbook.FollowHyperlink "S:\TimeSheets\" & init.Value & ".pdf"
With Application
.SendKeys ("%e"), True
.SendKeys ("a"), True
.SendKeys ("%e"), True
.SendKeys ("c"), True
.SendKeys ("%{F4}"), True
End With
End Sub

Sub StartPDFFile(init As Range)
Dim objWSH As Object
Set objWSH = CreateObject("WScript.Shell")
objWSH.Run Chr(34) & "S:\TimeSheets\" & init.Value & ".pdf" & Chr(34)
With Application
.SendKeys ("%e"), True
.SendKeys ("a"), True
.SendKeys ("%e"), True
.SendKeys ("c"), True
.SendKeys ("%{F4}"), True
End With
End Sub

mdmackillop
10-14-2009, 10:53 AM
Issue resolved, but I'm not clear why. After using the second code, the first then also failed. Building in delays showed that instead of sending "a", I needed to send "l", It seems a different Reader is opening, with a slightly different menu.

Now I just need to figure out how to cater for both options!