Solved

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

Posted on 2014-12-23
7
495 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 15

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
Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

 
LVL 15

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 15

Expert Comment

by:DrTribos
ID: 40515643
Glad to help
0

Featured Post

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

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

Suggested Solutions

Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

730 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