Reputation: 385
I have created a userform and added a webbrowser control. I am loading PDF images into the webbrowser control on the userform. What i would like to do is add a button to scroll the webbrowser downwards so i can see the next page of the pdf.
Upvotes: 1
Views: 921
Reputation: 149287
You can use the .Navigate
with #page=
to move to the relevant page. Here is an example in which we move to page no 2.
Dim FName As String
Private Sub UserForm_Initialize()
'~~> Replace this with the relevant file name
FName = "C:\Sample.pdf"
WebBrowser1.Navigate "file:///" & FName
End Sub
Private Sub CommandButton1_Click()
Dim PageNo As Long
PageNo = 2
'~~> I noticed that if I do not include
'~~> this line then the next .Navigate doesn't work
WebBrowser1.Navigate "About:Blank"
Wait 1 '<~~ Wait for a second
WebBrowser1.Navigate ("file:///" & FName & "#page=" & PageNo)
End Sub
Private Sub Wait(ByVal nSec As Long)
nSec = nSec + Timer
While nSec > Timer
DoEvents
Wend
End Sub
Upvotes: 1