- Sep 30, 2002
- 298
- 0
- 0
I'm trying to open a pdf to a certain page by clicking on a link in Excel. For some reason the #page=* command doesn't work for hyperlinks through Excel.
I'm currently using some visual basic code I found online, and I've managed to get the pdf to open in an ie window after double-clicking on a cell. Everything is working fine except now the end user would like the links to open in the same window and not create a new window every time they're clicked. I'm completely new to visual basic, and don't have much experience with programming in general. Is there an easy way to accomplish this? Here is the code that I'm using right now:
Thanks!
I'm currently using some visual basic code I found online, and I've managed to get the pdf to open in an ie window after double-clicking on a cell. Everything is working fine except now the end user would like the links to open in the same window and not create a new window every time they're clicked. I'm completely new to visual basic, and don't have much experience with programming in general. Is there an easy way to accomplish this? Here is the code that I'm using right now:
Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
Call PDFfile
End Sub
Sub PDFfile()
Dim myLink As String
Dim TargetPage As Double
Dim IE As Object
myLink = "c:\file.pdf"
If ActiveCell.Column = 3 Then
TargetPage = ActiveCell.Offset(0, -2)
If ActiveCell.Offset(0, -2) <> "" Then
Set IE = CreateObject("InternetExplorer.Application")
IE.Navigate myLink & "#page=" & TargetPage
IE.Visible = True
End If
ElseIf ActiveCell.Column = 4 Then
TargetPage = ActiveCell.Offset(0, -3)
If ActiveCell.Offset(0, -3) <> "" Then
Set IE = CreateObject("InternetExplorer.Application")
IE.Navigate myLink & "#page=" & TargetPage
IE.Visible = True
End If
End If
End Sub
Thanks!
