Results 1 to 12 of 12
  1. #1
    Uranium Lounger
    Join Date
    Dec 2000
    Location
    Salt Lake City, Utah, USA
    Posts
    9,508
    Thanks
    0
    Thanked 6 Times in 6 Posts

    Literal '[%]20' in filename (Office 10+, VBA 6)

    Lately I have noticed that some of the PDFs I download from prospect procurement websites include literal "%20" as part of the file name, e.g:
    Customer%20RFP%20Final%205-5-07.pdf

    This invalidates the hyperlink that the code attachment in <post#=443421>post 443421</post#> places in the Outlook Item body; when the link is clicked, the OS looks for a filename with spaces, not the literal string "%20".

    The obvious answer is to replace the literal "%20" with a space when saving the file (manually or in code), but issues can arise when we change the name of a prospect's file.

    I don't know HTML, so I don't know how to code for a literal "%20". Can someone advise?
    -John ... I float in liquid gardens
    UTC -7ąDS

  2. #2
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: Literal '[%]20' in filename (Office 10+, VBA 6)

    John,

    Just clutching at the edges of memory here. I think you use %% to get HTML to display a single % character.

    StuartR

  3. #3
    Uranium Lounger
    Join Date
    Dec 2000
    Location
    Salt Lake City, Utah, USA
    Posts
    9,508
    Thanks
    0
    Thanked 6 Times in 6 Posts

    Re: Literal '[%]20' in filename (Office 10+, VBA 6)

    <img src=/S/hmmn.gif border=0 alt=hmmn width=15 height=15> If I write the string %20 as HTML %%20, the link looks for "% " (%<space>).
    -John ... I float in liquid gardens
    UTC -7ąDS

  4. #4
    Platinum Lounger
    Join Date
    Feb 2002
    Location
    A Magic Forest in Deepest, Darkest Kent
    Posts
    5,681
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Literal '[%]20' in filename (Office 10+, VBA 6

    Hi John

    I think you have beaten me to the answer but I thought I would add some clarity to your answer as this is a very interesting (well it is to me <img src=/S/grin.gif border=0 alt=grin width=15 height=15>) issue when it this little % miscreant appears in URI's (The term URL was deprecated in 2005)

    There are a set of specific characters that are reserved characters which are:

    <table border=1><td>!</td><td>*</td><td>'</td><td>(</td><td>)</td><td>;</td><td>:</td><td>@</td><td>&</td><td>=</td><td>+</td><td>$</td><td>,</td><td>/</td><td>?</td><td>%</td><td>#</td><td>[</td><td>]</td></table>The only time that these can be used is if they have a reserved purpose and we sometimes see these in URI's where sites use the various characters to assist in navigation and the retrieval of datasets from back end databases.

    On an aside the teacher in me comes out ever so often and have a tendency to bark and growl at my screen when I see examples of links as you have shown in your example. This is the product of people saving Word documents and adding spaces in the document title to make it be seen in natural language to assist in search and retrieve in the Windows environment. I hate any link URI or mailto that has a space as the dreadful %20 get put in the places as you now suggest [gggrrr]

    So to assist us get around this problem we use Reserved characters after percent-encoding, like so:

    <table border=1><td>!</td><td>*</td><td>'</td><td>(</td><td>)</td><td>;</td><td>:</td><td>@</td><td>&</td><td>=</td><td>+</td><td>$</td><td>,</td><td>/</td><td>?</td><td>%</td><td>#</td><td>[</td><td>]</td>[<td>%21</td> <td>%2A</td> <td>%27</td> <td>%28</td> <td>%29</td> <td>%3B</td> <td>%3A</td> <td>%40</td> <td>%26</td> <td>%3D</td> <td>%2B</td> <td>%24</td> <td>%2C</td> <td>%2F</td> <td>%3F</td> <td>%25</td> <td>%23</td> <td>%5B</td> <td>%5D</td></table>So you have hit the nail on the head to try and change the %20 you have to add .........%25 & "20" in your VB code to create a string

    I could rattle on with this subject as it is a science in itself but I hope this will provide the essence of the subject
    Jerry

  5. #5
    Uranium Lounger
    Join Date
    Dec 2000
    Location
    Salt Lake City, Utah, USA
    Posts
    9,508
    Thanks
    0
    Thanked 6 Times in 6 Posts

    Re: Literal '[%]20' in filename (Office 10+, VBA 6

    Thanks, Jezza, the list of reserved characters is helpful. (I shouldn't have to worry about asterisk and slash, as they are not valid in file names - famous last words.)
    -John ... I float in liquid gardens
    UTC -7ąDS

  6. #6
    Uranium Lounger
    Join Date
    Dec 2000
    Location
    Salt Lake City, Utah, USA
    Posts
    9,508
    Thanks
    0
    Thanked 6 Times in 6 Posts

    Re: Literal '[%]20' in filename (Office 10+, VBA 6)

    But you put me on the right track. In any filename with % signs, I'll have to replace them with %25 in the hyperlink. Thanks! (One of those things that should have been obvious.)
    -John ... I float in liquid gardens
    UTC -7ąDS

  7. #7
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: Literal '[%]20' in filename (Office 10+, VBA 6

    Just to completely <img src=/S/pirate.gif border=0 alt=pirate width=22 height=18> the thread.

    I have always been amazed at the wide variety of characters that Windows allows in file names. I have one file on my hard drive with the delightful file name of
    <big>

  8. #8
    Platinum Lounger
    Join Date
    Feb 2002
    Location
    A Magic Forest in Deepest, Darkest Kent
    Posts
    5,681
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Literal '[%]20' in filename (Office 10+, VBA 6

    Well that is interest as that file is:

    %1%2%3%4%5%6%7%8%9,.txt so it looks like a system generated text file from something you have <img src=/S/nuts.gif border=0 alt=nuts width=15 height=15>

    I have created an HTML file and called it
    Jerry

  9. #9
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: Literal '[%]20' in filename (Office 10+, VBA 6

    Sadly, that just gives 404 bad request

    StuartR

    Edited to add
    It works now, but I am on a different PC so I don't know if you fixed something or it is a difference at my end.

    SR

  10. #10
    Platinum Lounger
    Join Date
    Feb 2002
    Location
    A Magic Forest in Deepest, Darkest Kent
    Posts
    5,681
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Literal '[%]20' in filename (Office 10+, VBA 6

    Nope, no change.....It may be a glitch somewhere or proof that it is not good practice <img src=/S/shrug.gif border=0 alt=shrug width=39 height=15>
    Jerry

  11. #11
    Uranium Lounger
    Join Date
    Dec 2000
    Location
    Salt Lake City, Utah, USA
    Posts
    9,508
    Thanks
    0
    Thanked 6 Times in 6 Posts

    Re: Literal '[%]20' in filename (Office 10+, VBA 6

    Jezza, do you have a recommended online resource on HTML "reserved characters" and their use, which I can review?

    (In the context of my original questions.) I ran into a situation where an actual file named "myfile[1].jpg" got changed by my "Replace" code to show as "myfile~1.jpg", and lo, the link worked, even though the actual target file name is "myfile[1].jpg". While it worked, it was an unexpected result, so I still don't really know what I'm doing, and I have more to learn!

    FWIW, the code snippet I'm using, where strSaveName is the actual file path & name, is:

    strHyperPFName = Replace(Replace(Replace(Replace(Replace(strSaveNam e, "%", "%25"), " ", "%20"), "!", "%21"), "#", "%23"), "&", "%26")
    strHyperPFName = Replace(Replace(Replace(Replace(Replace(strHyperPF Name, "?", "%3F"), "[", "%5B"), "]", "%5D"), "+", "%2B"), "=", "%3D")
    strHLinkText = "Attachment: <a href=file://" & strHyperPFName & " >file:///" & strSaveName & "</a>" ' final form of the link

    For that matter, I could use a good on-line intermediate reference on coding HTML, particularly the display text syntax.
    -John ... I float in liquid gardens
    UTC -7ąDS

  12. #12
    Platinum Lounger
    Join Date
    Feb 2002
    Location
    A Magic Forest in Deepest, Darkest Kent
    Posts
    5,681
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Literal '[%]20' in filename (Office 10+, VBA 6

    Hi John

    I have dug out a couple of references from a few university sites, what they lose in look and feel is certainly made up with good content

    Reserved and Special Characters

    and then to my disgust....but still good is from

    Wikipedia - Percent-encoding

    I think I have a third resource somewhere but will dig it out for you.
    Jerry

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •