Senin, 22 Juni 2020

Re: [MSAccessProfessionals] problem wit collecting file names

The question is "how are you trying to use your stored file full paths in code?"

I suspect that the problem is trying to use strings with quote marks on the end, and you're using the wrong quote marks.

You don't have to use quote marks at all, just put the full path string in a string variable.

The code below works fine in Access (A2007 and later) for opening files using their full path, even if it contains special characters:

Private Sub OpenFile()

    Dim strFilepath As String

    strFilepath = Me.txtFilePath & ""   'GET THE PATH FROM THER BOUND TEXTBOX.

    If strFilepath = "" Then GoTo exit_sub    'MAKE SURE YOU HAVE A FILE PATH.

    Application.FollowHyperlink strFilepath    'OPEN FILE.

exit_sub:

End Sub

 

If this doesn't do the trick, please explain HOW you are reading your paths into code and then trying to open them.

Hope this helps.

 

From: MSAccessProfessionals@groups.io <MSAccessProfessionals@groups.io> On Behalf Of onnoknol
Sent: Monday, June 22, 2020 6:03 AM
To: MSAccessProfessionals@groups.io
Subject: [MSAccessProfessionals] problem wit collecting file names

 

Hi friends, an  ion particulat Crystal)

I make good use of  crystal's code to  reasdd filenames into an access table.
And this works fine and fast..
 However, when I want to access the files later, using the stored fullpath,
I get errors, when an special character was in the filename. This is an example:

E:\exchange\complete\The Wire Tapper 11\15. un caddie renvers dans l~herbe - www.nonphilo.org.mp3

NB: Note: I already replace  ' with  ~ to avoid  problems when I use SQL code  where single quotes  are used as delimiters.

So, I have  two questions,
1: Is there a way to store the filenames in such a way  that they can be opened by the name that is stored?
2, I this is not so simple, is there a way to detect these names with  special characters,  so that I can write a routine to replace them on the fly?
 
Kind regards, Onno Knol

Tidak ada komentar:

Posting Komentar