?
Solved

Hyperlink With Spaces In Visual Basic

Posted on 2011-09-06
4
Medium Priority
?
209 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 15

Accepted Solution

by:
WalkaboutTigger earned 2000 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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

This article lists the top 5 free OST to PST Converter Tools. These tools save a lot of time for users when they want to convert OST to PST after their exchange server is no longer available or some other critical issue with exchange server or impor…
Outlook for dependable use in a very small business   This article is about using the Outlook application (part of Microsoft Office) in a very small business, or for homeowners where dependability and reliability are critical requirements. This …
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…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

650 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