Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to ad a hyperlink with a filename that has spaces 1

Status
Not open for further replies.

navyguy

Programmer
Aug 10, 2002
30
US
I am using the VB editor within Microsoft Outlook to make an attachment stripper. I am trying to insert hyperlink to the location of where the file was saved to within the body of the email. I am having problems with file names containing spaces.

Does anyone know how to do this?

I tried to use the following line of code

StrmyFileLocation = "C:\Documents and Settings\rlellis\My Documents\<file name here>
myItem.Body = myItem.Body & "file://" & StrmyFileLocation

The problem is that this creates a hyperlink but only to the point where there is a space. Therefore everything after "Documents" in the string does not get converted into the link.

I found out that whan you manually type file://filename within quotation marks the spaces are recognized.

However it doesn't seem to work when inserting a string in quotes in a VB macro as shown below:

myItem.Body = myItem.Body & Chr(34) & "file://" & StrmyFileLocation & Chr(34)

Everything after the space is not recognized.
 
Hi,

Turn on you macro recorder, insert the hyperlink to the file in question, turn off the macro recorder, and observe the results.

Skip,

[red]Be advised:[/red] [glasses]
Alcohol and Calculus do not mix!
If you drink, don't derive! [tongue]
 
I appreciate the suggestion but there isn't a macro recorder in MSOutlook.
 
Have you tried this ?
StrmyFileLocation = Replace(StrmyFileLocation, " ", "%20")

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Thanks. It worked! I guess the %20 gets treated as a space?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top