ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   hyperlink breaks if space within hyperlink (https://www.excelbanter.com/excel-programming/273255-hyperlink-breaks-if-space-within-hyperlink.html)

Dim

hyperlink breaks if space within hyperlink
 
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 "
.Body = Sheets("Main").Range("s5")
.send
end with


thanks in advance for a help.
Dim

Jerry Park

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

Dim wrote:
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 "
.Body = Sheets("Main").Range("s5")
.send
end with


thanks in advance for a help.
Dim





All times are GMT +1. The time now is 08:52 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com