Solved

Hyperlink With Spaces In Visual Basic

Posted on 2011-09-06
4
195 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
Comment Utility
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
Comment Utility
replace
space

Open in new window

by %20

.Replace(" ","%20")

Open in new window

0
 
LVL 82

Expert Comment

by:leakim971
Comment Utility
0
 

Author Closing Comment

by:Tectonic
Comment Utility
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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
VB.net PaintEventArgs Handling. 10 26
Word Template Mail merge with vb.net 4 38
Set form below another form 3 25
outlook 3 15
Set OWA language and time zone in Exchange for individuals, all users or per database.
If you don't know how to downgrade, my instructions below should be helpful.
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 …
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

743 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

14 Experts available now in Live!

Get 1:1 Help Now