简体   繁体   中英

Print Screen PDF file with vba

I want to open a PDF file and print the subaddress that i specified, but when i use Application.SendKeys "(%{1068})" just print screen Userform. My issue is how print screen just subaddress Rating Changes.

enter code here
Private Sub AlteraRating_Click()
Dim strFolde As String, Month As String, Year As String, strFile As String

Month = Format(SalvaData, "mm")
Year = Format(SalvaData, "yyyy")
pdfData = Format(SalvaData, "yyyymmdd")
strFolder = "C:\Report\Report of Investments\" & Year & "\" & Month & "\"


strFile = strFolder & "RAI_INFRAPREV PLANO CV_F03148_" & pdfData & ".pdf"
ThisWorkbook.FollowHyperlink strFile, "Rating Changes"

Application.SendKeys "(%{1068})"
DoEvents

End Sub

Try using the following code in order to open the PDF, FollowHyperlink won't keep it open long enough to print screen.

Dim shell As Object
Set shell = CreateObject("WScript.Shell")
shell.Run Chr(34) & strFile & Chr(34), 1, False

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM