Open multiple pdf

puffer317

Registered User.
Local time
Yesterday, 19:50
Joined
Apr 15, 2008
Messages
18
Hello all. I'm trying to open pdf files from access. The files are in different folders depending on the type they are. Everything works fine the first time I run it, but if I run it again without closing Acrobat nothing happens. I would like to be able to open multiple pdf's or one after the other. Here is what I have so far.

Private Sub view_Click()
Dim strValue
Dim retVal
Dim cmd As String
Dim fullPath As String
Dim strFolder As String
Dim strTechSelector
strTechSelector = [Tech Code]
'choose the folder depending on the value in the tech code column
Select Case strTechSelector
Case "UC"
strFolder = "UrethanePDF\"
Case "DC"
strFolder = "DWGEMIPDF\"
Case "PC"
strFolder = "PlasticsPDF\"
Case "TC"
strFolder = "TextilesPDF\"
End Select
'set strValue to the tech code column plus the number column example dc + 4609 is dwg DC4609
strValue = [Tech Code] & [NUMB]
'fullPath is the path to the dwgs
'1* is a naming and revision
fullPath = "U:\EDMIndex\PROJECTS\" & strFolder & strValue & "1*.pdf"
cmd = Chr(34) & "C:\Program Files\Adobe\Acrobat 6.0\Acrobat\Acrobat.exe" & Chr(34) & fullPath & Chr(34)
retVal = Shell(cmd, vbNormalFocus)

End Sub

Thank you for your time.
 
Last edited:
I had a wee play with your code.

I'm assuming that where it says ...1*.pdf, that you want it to open all files that it finds?

I don't know if this is the most efficient way of doing it, but it should work.

Code:
Private Sub view_Click()
Dim strValue
Dim retVal
Dim cmd As String
Dim fullPath As String
Dim strFolder As String
Dim strTechSelector

[B]Dim strFile As String[/B]

strTechSelector = [Tech Code]
'choose the folder depending on the value in the tech code column
Select Case strTechSelector
Case "UC"
strFolder = "UrethanePDF\"
Case "DC"
strFolder = "DWGEMIPDF\"
Case "PC"
strFolder = "PlasticsPDF\"
Case "TC"
strFolder = "TextilesPDF\"
End Select
'set strValue to the tech code column plus the number column example dc + 4609 is dwg DC4609
strValue = [Tech Code] & [NUMB]
'fullPath is the path to the dwgs
'1* is a naming and revision

fullPath = "U:\EDMIndex\PROJECTS\" & strFolder & strValue & "1*.pdf"

[B]strFile = Dir(fullPath)

'should be able to loop through all files it finds now
Do While strFile <> ""

    Application.FollowHyperlink strFile
    
    strFile = Dir
    
Loop[/B]


End Sub

Regards,
Pete
 
Thank you very much, but I should have been a little more clear. What I am trying to do is have acrobat come back into focus and open another file. When i choose a record and click view the code works perfectly. Acrobat is opened and the drawing is displayed. If I go back to Access and select another record and click view nothing happens this time. If I close Acrobat and then go to Access and click view it works fine again. I would rather not wait for Acrobat to open and close in between every view.
I hope that makes sense and thanks again
 
If you use the Application.FollowHyperlink Method, it will work.
The only thing it does (or rather doesn't) do is close the last file you were looking at.
In between, Acrobat isn't closing and re-opening (well it doesn't seem to be on my computer at least!).

This means - if Acrobat is already open, it will open a new window within Acrobat with the new file in it, and if it isn't open, it will start a new instance of Acrobat.

However, you could try and take control of Acrobat in a more complete way.
I googled for it and there were a number of links showing how to use Acrobat with VBA. I'm thinking that it's probably possible to start an instance of Acrobat (in the background) when the form opens (or at least check for an open instance of it), and then opening and closing documents as required within that instance.

Sorry I can't be of more help,

Regards,
Pete
 
sweet

That's a great help. I'm going to try it first thing tomorrow. I think it will solve the window problem and the drawing revision number problem. Thanks again. I'll let you know how it goes.
 

Users who are viewing this thread

Back
Top Bottom