File Extensions

honey2wood

Registered User.
Local time
Today, 01:40
Joined
Feb 16, 2010
Messages
43
Hi,
I cant seem to find anything that answers my question on the forum but I expect someone knows where I should have looked but here goes,

I have a database that looks up files in a certain folder then as hyperlinks to that file and opens it.

I can do that but the files I am looking at have different extensions. Mainly .doc, .docx and .pdf

At the moment the code just looks for pdf but is there a way to make it open any of them.

This is what I have now

Private Sub Hyperlink_Click()
Dim QuoteNo As String
QuoteNo = "\\2003SERVER\Company\Quality\Defective Goods\DGRs\" & "DGR-" & Me.DGR_No & ".pdf"

On Error GoTo Err_CannotOpenEnquiry
Application.FollowHyperlink QuoteNo
Exit_Err_CannotOpenEnquiry:
Exit Sub
Err_CannotOpenEnquiry:
MsgBox Err.Description
Resume Exit_Err_CannotOpenEnquiry

End Sub

What I need is an equivelent to * on Excel.
Does anyone have any thoughts on this please.

Graham
 
This type of thing may work as a work - around.

It has a list of extensions, and will try to open all the files of a given name with each of the extensions in your list.

Code:
Sub testExt()
          Dim x As String
          Dim i As Integer
          Dim MyTypes(3) As String
10        MyTypes(1) = ".doc"
20        MyTypes(2) = ".docx"
30        MyTypes(3) = ".pdf"
40        On Error GoTo testExt_Error

50        x = "C:\Documents and Settings\Garay\My Documents\"
60        For i = 1 To 3
70            Application.FollowHyperlink x & "criteria" & MyTypes(i)
80            Debug.Print x & "criteria" & MyTypes(i)
90        Next i

100       On Error GoTo 0
110       Exit Sub

testExt_Error:
120       If Err.number = 490 Then   'file not found
130           Resume Next
140       Else
150           MsgBox "Error " & Err.number & " (" & Err.Description & ") in procedure testExt of Module AWF_Related"
160       End If
End Sub
 
Last edited:
Hi JDraw,

Many thanks for the reply. This is just what I needed. Sorry I have not got back before but have been away.

Graham
 

Users who are viewing this thread

Back
Top Bottom