Solved

Hyperlink With Spaces In Visual Basic

Posted on 2011-09-06
4
199 Views
Last Modified: 2012-05-12
I have some code that saves a file to a location based on a path the user selects. I have the location of that saved location stored in a string called findShare, I go to put that location in the footer of a message and if it contacts a space in it the hyperlink will be broken.

I am also using some code that replaces the Network drive name with the unc address of the item. If I can get a hyperlink with the network drive name that will be a plus but I am more worried about just getting a full hyperlink so they can click it and go directly to it.

Thanks in advance.

 File Name With Space File Name Without Space
Dim findShare As String

findShare = theFolderBrowser.SelectedPath & "\" & myAttachments(i).DisplayName()

findShare = findShare.Replace("G:", "\\Server\Share1")

myItem.htmlBody = myItem.htmlBody & _
"<br>File: " & findShare & vbCrLf

Open in new window

0
Comment
Question by:Tectonic
  • 2
4 Comments
 
LVL 15

Accepted Solution

by:
WalkaboutTigger earned 500 total points
ID: 36491797
Remember what a hyperlink is - an anchor with a text description.

Dim findShare, findShareHTML as String

findShareHTML = findShare.Replace(" ", "%20")
myItem.htmlBody = myItem.htmlBody & _
"<br>File: " & "<a href=" & Chr(34) & findShareHTML & Chr(34) & ">" & findShare & "</a>" & vbCrLf

I don't have my development machine here to try it, but give it a shot.
0
 
LVL 82

Expert Comment

by:leakim971
ID: 36491803
replace
space

Open in new window

by %20

.Replace(" ","%20")

Open in new window

0
 
LVL 82

Expert Comment

by:leakim971
ID: 36491819
0
 

Author Closing Comment

by:Tectonic
ID: 36491851
That is exactly what I was missing. I was looking high and low for that somewhere on the web but couldn't find it. I knew I had to do something with the %20 but didn't know how to get it in there.

It worked perfectly adding it to the code.

Thanks.
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

Suggested Solutions

Following basic email etiquette rules will help you write a professional email and achieve a good, lasting impression with your contacts.
Find out what you should include to make the best professional email signature for your organization.
To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
Many of my clients call in with monstrous Gmail overloading issues with Outlook. A quick tip is to turn off the All Mail and Important folders from synching. Here is a quick video I made to show you how to turn off these and other folders in Gmail s…

839 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