【发布时间】:2018-05-01 21:05:17
【问题描述】:
我有以下宏,旨在快速切换两个 PDF。 8 次快速切换后,宏应转到两个 PDF 的下一页并重复该过程。不幸的是,宏滚动首先声明为 PDF。任何想法如何修改它?
Private Declare PtrSafe Function BringWindowToTop Lib "user32" (ByVal lngHWnd As LongPtr) As LongPtr
Private Declare PtrSafe Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As LongPtr
Private Declare PtrSafe Sub Sleep Lib "kernel32" (ByVal dwMiliseconds As Long)
Sub switching_pdfs()
Dim i As Integer, j As Integer
ptr1 = FindWindow(vbNullString, "Some PDF 1.pdf - Acrobat Reader")
ptr2 = FindWindow(vbNullString, "Some PDF 2.pdf - Acrobat Reader")
For i = 1 To 30
For j = 1 To 4
BringWindowToTop (ptr1)
Sleep 100
BringWindowToTop (ptr2)
Sleep 100
Next j
BringWindowToTop (ptr1)
Application.SendKeys "{RIGHT}": Sleep 500: DoEvents 'should move to the next page in the first PDF
BringWindowToTop (ptr2)
Application.SendKeys "{RIGHT}": Sleep 500: DoEvents 'should move to the next page in the second PDF
Next i
End Sub
我也尝试使用 SendMessage,但它不想将任何 PDF 移动到下一页。
【问题讨论】: