Opening a PDF to specific page through field reference

ColinGrant

New member
Local time
Today, 07:09
Joined
Jun 13, 2011
Messages
3
Hello,
I have a database full of part numbers, that have standard(Blueprints essentially) images that go with them. So, I want to have a button that allows the user to click and see the image of the part and all the details (Listed in a PDF). My code works perfect when I tell it to go to a specific page number. I've created a field called Page, that has the page numbers of all the parts standards, so instead of using an integer value, I am trying to have it take the number from the field I created(Page).

I know that I haven't explained this all th best, but I will be glad to clear up any questions regarding my issue. My code is as follows:

Code:
Private Sub ViewStandard_Click()
'open pdf at page #
  Dim pageNum As String
  Dim fileloc As String
  Dim bookmark As String
 
  pageNum = Me.myPage
  Debug.Print pageNum
 
  pat1 = """C:\Program Files\Adobe\Reader 9.0\Reader\AcroRd32.exe"""
 
  'pat2 = "/A ""page=20"""
  pat2 = "/A " & pageNum & ""
  Debug.Print pat2
 
 
  pat3 = """G:\File\Path\Here\PDF.pdf"""
 
  Shell pat1 & " " & pat2 & " " & pat3, vbNormalFocus
 
  'fileloc = location of all hoses pdf
  'bookmark = fileloc & pagenum
 
End Sub

Thanks for taking the time to read this, I hope to hear from you :)

UPDATE

I've solved my problem as far as getting the data from the path.

Code:
pageNum = Me.myPage

This code gets the correct page number from the standard being viewed, which is perfect. Now, my main problem is taking this and inputting into my next line of code to tell it to open this value. So if, PageNum = Me.myPage comes out to equal 100, I need it to open to page 100. The commented out section is how it works with a specific number.

Figured I'd try help clear things up, aswell as give an update on my status!
 
Last edited:
I have solved my issue!

This code successfully opens the PDF to the correct page as defined by the Page field. So, if anyone else has wanted to to this (Create a button to open a PDF) and have it relate directly to a certain field, this is how!

Code:
Private Sub ViewStandard_Click()
'open pdf at page #
  Dim pageNum As String
  Dim myCmd As String
    pageNum = Me.myPage
        Debug.Print pageNum
        
            pat1 = """C:\Program Files\Adobe\Reader 9.0\Reader\AcroRd32.exe """
                'Debug.Print pat1
            pat2 = "/A ""page=" & pageNum & """"
            pat3 = """G:\File\Location\Filename.pdf"""
                'Debug.Print pat3
  
  
  Debug.Print pat1 & " " & pat2 & " " & pat3
  
  Shell pat1 & " " & pat2 & " " & pat3, vbNormalFocus
  
End Sub

The main problem was that I was exlcuding the basic "page=" parameter!

Thanks to anyone may have read over this :)
 

Users who are viewing this thread

Back
Top Bottom