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
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