Adamsan
Adamsan

Reputation: 662

VBA: Howto open a file, that has # -characters in it's name?

I have an access database front-end, and on a buttonclick, certain files are opening, with the software they are associated with. The code to achieve this is the following:

If (IsNull(Me.filepath)) Then Exit Sub
If (FileFolderExists(Me.filepath)) Then
    If (isFolder(Me.filepath)) Then
        Shell "explorer.exe " & Me.filepath, vbNormalFocus
    Else
        FollowHyperlink Me.filepath
    End If
End If

Well, this is all good and working, but the file won't open, if the filename contains # symbols. Wich is unfortunatly the case: Some of the filenames look like this: 13_tamogatodontes##1911_201001.pdf

I tried to find some answers with google, and on msdn, did not found any useful info. Does somebody know how to solve this problem?

Upvotes: 2

Views: 2992

Answers (1)

Matt Donnan
Matt Donnan

Reputation: 5003

You need to enclose your filename in quotes also, e.g:

Shell "explorer.exe " & "" & Me.filepath & "", vbNormalFocus

I'm not sure if it's 2 or 3 double quotes but have a play around : )

Upvotes: 1

Related Questions