Question : Think I need to convert hyperlink addresses in Access 2007 to absolute paths?

Hi, I have a database form containing a subform which allows a user to 'attach' a series of documents .. this is done simply with a command button which runs the Insert Hyperlink command.
So far so good as the 'attached documents' can be clicked on and opended as expected.

I now need to be able to attach these documents to an email. I already have the code to formulate / send the email but my main problem is deriving the file paths from the hyperlink fields in the attachments table.

My email button strips the actual filenames from the hyperlinks (discarding #'s etc) and puts them in an array before passing to the 'send_message' procedure. I have noticed that the filenames are stored as relative paths such as '..\image.jpg' for example and the send_message procedure then gives an error saying it can't find the file at the .attachments.add line of my code extract. Also, the IsMissing function verifies the file exists ok .. the error occurs at the end of the line - actual error message is shown in the attached image.

As an example, the filename "..\logo.bmp" causes this error although I have manually entered some other filenames such as 'c:\temp\quote.pdf' and these work fine.

I assume this is because I need absolute file-paths as I can't see any other reason so .. is there a way to store the absolute paths instead; or even convert the relative paths with a function? Any other suggestions most welcome.

My worse case scenario is to prevent local files being selected at all, especially as other users could not access these from the database anyway. Thsi also implicitly allows only full paths on a network drive which would be available to everyone, security not withstanding.

Thanks.
Code Snippet:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
With OutMail
        .To = strTo
        .Subject = strSubj
        .Body = strText
        'Add attachments from array
        For i = 0 To UBound(strAttach,2)
            If Not IsMissing(strAttach(1, i)) Then .attachments.Add (strAttach(1, i))
        Next
        .Display
        .BodyFormat = 2 'olFormatHTML
   End With

Answer : Think I need to convert hyperlink addresses in Access 2007 to absolute paths?

Sorry about that.  Problems between keyboard and chair...let's try again!

Yup, you'll need UNC file paths to create Outlook attchments .  The hyperlink addresses are relative to the parent folder of the mdb file you are using which you could get like this:
 
Public Function RelativeFolderPath() As String
'This function needs a reference to C:\Windows\System\wshom.ocx or similar
Dim objFileSystem As New FileSystemObject
Dim strFilePath As String
   
    strFilePath = objFileSystem.GetParentFolderName(CurrentDb.Name)
    RelativeFolderPath = objFileSystem.GetParentFolderName(strFilePath)
End Function
 
However, if you move any of the database files the hyperlinks are relative & they will fail...   So, using hyperlinks isn't a good idea.  You could allow users to pick files from a folder and record the file paths.  It takes an age to describe fully so I've attached a sample db which does just that.  

The display form has records with pseudo hyperlinks.  You can:
1.  Add new or update "hyperlinks" by selecting new or existing records, then clicking on "Browse..."
2.  update the "hyperlink" description by typing in the text box.
3.  Open the file by double-clicking in the text box

Simples... :-)
 
File System Access Database
 
Random Solutions  
 
programming4us programming4us