hyperlink breaks if space within hyperlink

D

Dim

i'm trying to send out email with a hyperlink (path) to a file on a
network.
Email generated from Excel2K using outlook2K.

Problem is that hyperlink contains a space within the path.. when link
is created in a cell it's just fine but when i try to move that link
to the body of a email that where the brake happens:
if that path is created in the cell
"\\ny-gdpcommod-1\Ferm$\Power (space) Operations\filename.xls" and
then i insert that hyperlink into email body through a variable string
or getting value directly from a cell it assumes that hyperlink is
only up to that space between Power and operations
"\\ny-gdpcommod-1\Ferm$\Power "



i'm generating a hyperlink in spreadsheet to a file with the following
code:

With Worksheets("Main")
.Hyperlinks.Add .Range("s5"), _
"\\ny-gdpcommod-1\Ferm$\Power Operations\Test\DailyPosition_" &
Format(dDate, "YYYYMMDD") & ".xls"

End With


and then i'm trying to asign that hyperlink within the body of email:

Set objOutlook = CreateObject("Outlook.Application")
Set objMailItem = objOutlook.CreateItem(olMailItem)

With objMailItem
.Recipients.Add "(e-mail address removed)"
.Body = Sheets("Main").Range("s5")
.send
end with


thanks in advance for a help.
Dim
 
J

Jerry Park

A valid URL does not contain spaces. Try replacing each space with '%20'
(without the quotes).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top