Create Hyperlink in an email (spaces n text issue)

  • Current Code



    the problem: Thisworkbook.Path includes spaces in the path. The Hyperlink that this code generates always cuts off at the first " " (space) that it comes across, anythign to the right of the space is left off of the generated hyperlink, causing an incorrect path when you click on the hyperlink.


    For instance, "Z:\workbook path\excelfile.xlsx" would end up being "Z:\workbook" as a hyperlink because everything to the right of the space will be cut off.


    How can i solve this problem without eliminating spaces from every path?

  • Re: Create Hyperlink in an email (spaces n text issue)


    you don't have quotes "" in your argument, these are used in HTML to group characters in a single string. Try This:


    Code
    1. "<a href=""" & ThisWorkbook.Path & "\Archive\"">Report Location</a>"


    At the moment, your code produces the string - <a href=Z:\Workbook Directory\Archive\>Report Location</a>


    Whereas it needs to be - <a href="Z:\Workbook Directory\Archive\">Report Location</a>


    html will assume that your string finishes at the word "Workbook" (in this example) unless you use quotation marks to indicate that it is part of a greater string.


    Hope that makes sense.