Solved

Hyperlink With Spaces In Visual Basic

Posted on 2011-09-06
4
198 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

This process describes the steps required to Import and Export data from and to .pst files using Exchange 2010. We can use these steps to export data from a user to a .pst file, import data back to the same or a different user, or even import data t…
Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This Experts Exchange video Micro Tutorial shows how to tell Microsoft Office that a word is NOT spelled correctly. Microsoft Office has a built-in, main dictionary that is shared by Office apps, including Excel, Outlook, PowerPoint, and Word. When …

803 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