Hyperlink in email body - spaces

SlinkyWheels

Board Regular
Joined
Jan 5, 2007
Messages
217
Hi

I am using the following code in Excel 2003 to add a hyperlink into an email.

Public Sub email()

Dim fname As String

Set ol = CreateObject("Outlook.application")
Set NewMessage = ol.CreateItem(olMailItem)
fname = ActiveWorkbook.Path & "\" & ActiveWorkbook.Name

With NewMessage
.to = "someone@soomewhere.co.uk"
.Subject = "This is only a test!"
'Insert body and Hyperlink below...
.Body = "file://" & fname
.Display
End With

Set ol = Nothing
Set NewMessage = Nothing

End Sub

The problem I have is that the file path contains a space so when this is added to the body of the email, the hyperlink I am trying to create stops at the space in the file path.

I have read I need to do something with "%20" but I am not sure what?

Can anyone shed any light on this for me?
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).

Forum statistics

Threads
1,214,945
Messages
6,122,397
Members
449,081
Latest member
JAMES KECULAH

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top