![]() ![]() To put that altogether, you will also need to know the caption of the workbook where you want to paste the data in order to re-activate the window. SendMessage lParent, WM_CLOSE, 0, CLng(0) SendMessage lParent, WM_CLOSE, 0, CLngPtr(0) 'Find the handle of the main/parent window. Public Sub ClosePDF(ByVal strPDFPath As String) (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" _ ![]() (ByVal hwnd As LongPtr, ByVal wMsg As LongPtr, ByVal wParam As LongPtr, ByVal lParam As Any) As LongPtr Private Declare PtrSafe Function SendMessage Lib "user32" Alias "SendMessageA" _ Private Declare Function SetForegroundWindow Lib "user32" (ByVal hwnd As Long) As Long Private Declare PtrSafe Function SetForegroundWindow Lib "user32" (ByVal hwnd As LongPtr) As Long ![]() I use the following code to close the PDF file, which again requires using the FindWindow code. Timing can get tricky too so best to put some wait commands in. Then send the Ctrl+A and finally Ctrl+C key commands. One way around this is to send the Shift+Ctrl+H key sequence to put acrobat into auto-scroll mode. If the Page Display in Acrobat is set by default to Enable Scrolling, then Ctrl+A will highlight the entire file, otherwise only the active page. Once the PDF file is activated the SendKeys commands can be used.Īgain, this can get tricky. LParent = FindWindow("AcrobatSDIWindow", strPDFName & " - Adobe Acrobat Pro") LParent = FindWindow("AcrobatSDIWindow", strPDFName & " - Adobe Reader") StrPDFName = Mid(strPDFPath, InStrRev(strPDFPath, "\") + 1, Len(strPDFPath))ĭo Until Now() > dtStartTime + TimeValue("00:00:05") ![]() Public Function IsAcrobatOrPro(ByVal strPDFPath As String) As Integer Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long Private Declare PtrSafe Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As LongPtr ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |