Solved

How do I make a hyperlink that includes spaces in email VBA code?

Posted on 2014-12-23
7
424 Views
Last Modified: 2015-01-28
I really have two questions (but #2 is predicated on #1 working):
1)  The code below shows the body of an email with a hyperlink to a path which has spaces in it.  The code works fine to a directory path without spaces.  When it reaches a space however, the code doesn't notice any part of the path beyond the space.
2)  Since I haven't gotten beyond #1 above, I just want to make sure I can use variants within the path to further identify the directory.
>>>>> How do I get beyond #1 question so a space is acceptable to VBA in this hyperlink?

Dim InvPer As String
Dim NewRef3 As String
NewRef3 = Format(Date(), "yyyy")
InvPer = Format(Date(), "mm.yy")
 
.HTMLBody = "Mary,   " & "<BR>" & "<BR>" & _
            "The " & Chr(34) & "<I>" & "Trial Balance.xlsx" & "</I>" & Chr(34) & " file in the " & _
        '"<a href=\\carefirst.com\corp\shared\Finance\Finance Shared\Beeline\Invoices>" & _
            "S:\Finance\Finance Shared\Beeline\Invoices\" & NewRef3 & "\" & InvPer & "\" & "</a>" & _
            " directory has been updated.  " & "<BR>" & "<BR>" & _
            "Please notify if I can be of further assistance. " & "<BR>" & "<BR>" & _
            "Thanks. "
0
Comment
Question by:CFMI
  • 3
  • 3
7 Comments
 
LVL 5

Assisted Solution

by:Hakan Yılmaz
Hakan Yılmaz earned 250 total points
ID: 40515620
Try
vbNewLine or vbCrLf
0
 
LVL 14

Assisted Solution

by:DrTribos
DrTribos earned 250 total points
ID: 40515622
Use %20 instead of space
0
 
LVL 5

Expert Comment

by:Hakan Yılmaz
ID: 40515627
Ah, i tought you mean newlines.
0
Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 
LVL 14

Accepted Solution

by:
DrTribos earned 250 total points
ID: 40515628
Using variable should be ok to build the path
0
 
LVL 5

Assisted Solution

by:Hakan Yılmaz
Hakan Yılmaz earned 250 total points
ID: 40515630
You can use double quotes as escape character in string.
So you can make it like HTMLBody="<a href=""this is my href with spaces"">this is my hyperlink</a>"
0
 
LVL 1

Author Closing Comment

by:CFMI
ID: 40515640
You guys are sooo on the ball.  . . . . SO FAST that my question was answered AND CORRECT almost before I asked!!!

THANK YOU.  Happy Holidays.
0
 
LVL 14

Expert Comment

by:DrTribos
ID: 40515643
Glad to help
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Access Runtime 2010 Error 17 32
MS Access to SQL Conversion - Bit and Yes/No Datatypes 12 46
Excel 2016 - Black cell borders 11 27
Search Form not Querying 2 11
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
Recently Microsoft released a brand new function called CONCAT. It's supposed to replace its predecessor CONCATENATE. But how does it work? And what's new? In this article, we take a closer look at all of this - we even included an exercise file for…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
Learn how to create and modify your own paragraph styles in Microsoft Word. This can be helpful when wanting to make consistently referenced styles throughout a document or template.

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now