+ Reply to Thread
Results 1 to 9 of 9

Links do not work once sent via outlook

Hybrid View

pauluk Links do not work once sent... 09-29-2009, 07:14 AM
royUK Re: Links do not work once... 09-29-2009, 07:23 AM
DonkeyOte Re: Links do not work once... 09-29-2009, 07:26 AM
pauluk Re: Links do not work once... 09-29-2009, 07:31 AM
DonkeyOte Re: Links do not work once... 09-29-2009, 07:32 AM
pauluk Re: Links do not work once... 09-29-2009, 08:12 AM
pauluk Re: Links do not work once... 09-30-2009, 06:01 AM
pauluk Re: Links do not work once... 09-30-2009, 06:35 AM
pauluk Re: Links do not work once... 09-30-2009, 08:22 AM
  1. #1
    Registered User
    Join Date
    01-21-2004
    Location
    Liverpool
    MS-Off Ver
    2003
    Posts
    88

    Links do not work once sent via outlook

    Hi all,

    Am using ronebruin mail VBA to send mails from outlook http://www.rondebruin.nl/mail/folder3/mail4.htm However the links do not appear to work.

    If a cell has a hyperlink such as www.google.co.uk then it appears but it is no active. The links work in excel but just not when sent via outlook. any ideas???

    Thanks in advance
    regards
    Paul
    http://www.frontlineuk.com
    FrontLineUK

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Links do not work once sent via outlook

    Which set of code are you actually using?
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  3. #3
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Links do not work once sent via outlook

    could you post a sample file with a range reflecting your real file, ie that contains links which are failing to generate correctly in OL ?

    is OL displaying the messages in plain text ?

    Quote Originally Posted by royUK View Post
    Which set of code are you actually using?
    Roy, other than the notes (binding etc) all the code is required - the 2nd section is a Function for converting the Range

  4. #4
    Registered User
    Join Date
    01-21-2004
    Location
    Liverpool
    MS-Off Ver
    2003
    Posts
    88

    Re: Links do not work once sent via outlook

    The code is as per the link but attached below.

    As for the links it is every hyperlink in the excel file, so if i create a hyperlink in a cell it works in excel but once it has been outputted by the code it is no longer a hyper link. I am assuming that it may be something with the rangeto html function but from looking at it basically saves it as a web page and publish's it

    Sub Mail_Selection_Range_Outlook_Body()
    ' Don't forget to copy the function RangetoHTML in the module.
    ' Working in Office 2000-2007
        Dim rng As Range
        Dim OutApp As Object
        Dim OutMail As Object
    
        Set rng = Nothing
        On Error Resume Next
        'Only the visible cells in the selection
        Set rng = Selection.SpecialCells(xlCellTypeVisible)
        'You can also use a range if you want
        'Set rng = Sheets("YourSheet").Range("D4:D12").SpecialCells(xlCellTypeVisible)
        On Error GoTo 0
    
        If rng Is Nothing Then
            MsgBox "The selection is not a range or the sheet is protected" & _
                   vbNewLine & "please correct and try again.", vbOKOnly
            Exit Sub
        End If
    
        With Application
            .EnableEvents = False
            .ScreenUpdating = False
        End With
    
        Set OutApp = CreateObject("Outlook.Application")
        OutApp.Session.Logon
        Set OutMail = OutApp.CreateItem(0)
    
        On Error Resume Next
        With OutMail
            .To = "ron@debruin.nl"
            .CC = ""
            .BCC = ""
            .Subject = "This is the Subject line"
            .HTMLBody = RangetoHTML(rng)
            .Send   'or use .Display
        End With
        On Error GoTo 0
    
        With Application
            .EnableEvents = True
            .ScreenUpdating = True
        End With
    
        Set OutMail = Nothing
        Set OutApp = Nothing
    End Sub
    Function RangetoHTML(rng As Range)
    ' Changed by Ron de Bruin 28-Oct-2006
    ' Working in Office 2000-2007
        Dim fso As Object
        Dim ts As Object
        Dim TempFile As String
        Dim TempWB As Workbook
     
        TempFile = Environ$("temp") & "/" & Format(Now, "dd-mm-yy h-mm-ss") & ".htm"
     
        'Copy the range and create a new workbook to past the data in
        rng.Copy
        Set TempWB = Workbooks.Add(1)
        With TempWB.Sheets(1)
            .Cells(1).PasteSpecial Paste:=8
            .Cells(1).PasteSpecial xlPasteValues, , False, False
            .Cells(1).PasteSpecial xlPasteFormats, , False, False
            .Cells(1).Select
            Application.CutCopyMode = False
            On Error Resume Next
            .DrawingObjects.Visible = True
            .DrawingObjects.Delete
            On Error GoTo 0
        End With
     
        'Publish the sheet to a htm file
        With TempWB.PublishObjects.Add( _
             SourceType:=xlSourceRange, _
             Filename:=TempFile, _
             Sheet:=TempWB.Sheets(1).Name, _
             Source:=TempWB.Sheets(1).UsedRange.Address, _
             HtmlType:=xlHtmlStatic)
            .Publish (True)
        End With
     
        'Read all data from the htm file into RangetoHTML
        Set fso = CreateObject("Scripting.FileSystemObject")
        Set ts = fso.GetFile(TempFile).OpenAsTextStream(1, -2)
        RangetoHTML = ts.ReadAll
        ts.Close
        RangetoHTML = Replace(RangetoHTML, "align=center x:publishsource=", _
                              "align=left x:publishsource=")
     
        'Close TempWB
        TempWB.Close savechanges:=False
     
        'Delete the htm file we used in this function
        Kill TempFile
     
        Set ts = Nothing
        Set fso = Nothing
        Set TempWB = Nothing
    End Function

  5. #5
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Links do not work once sent via outlook

    I'm running 2007 presently but I could only replicate the lack of link issue if I set OL to display the message in Plain text format... I will try and test on a pre 2007 environment later (unless someone else chooses to in the meantime...)

  6. #6
    Registered User
    Join Date
    01-21-2004
    Location
    Liverpool
    MS-Off Ver
    2003
    Posts
    88

    Re: Links do not work once sent via outlook

    My out look is set to rich text

  7. #7
    Registered User
    Join Date
    01-21-2004
    Location
    Liverpool
    MS-Off Ver
    2003
    Posts
    88

    Re: Links do not work once sent via outlook

    Am using OL 2003 XL 2003

    OL mail format is set to Rich text no links working
    OL mail format set to HTML no links working
    OL mail format to plain text no links working

    If i copy and paste manually into ol links work.

    I am assuming that it is the rangetohtml function at first i though it was the because the HTMLtype was set to xlHtmlstatic but there is no other selction unless you wantinteractivity which means activex which i cannot use due to restrictions. Am I there for correct to assume that if my network security setting prohibit activex then an alternative solution needs to be sourced?

  8. #8
    Registered User
    Join Date
    01-21-2004
    Location
    Liverpool
    MS-Off Ver
    2003
    Posts
    88

    Re: Links do not work once sent via outlook

    Ok after a looking at the function it is the following code snip that is causing the hyperlinks to be lost
        With TempWB.Sheets(1)
            .Cells(1).PasteSpecial Paste:=8
            .Cells(1).PasteSpecial xlPasteValues, , False, False
            .Cells(1).PasteSpecial xlPasteFormats, , False, False
            .Cells(1).Select
    As the function uses pastes special to paster the values.
    In my spreadsheet people use the insert>hyperlink for the hyperlinks.
    What would i need to change? My mind has drew a blank
    It's prob the following line which needs changing just to astright forward
    activecells.paste

  9. #9
    Registered User
    Join Date
    01-21-2004
    Location
    Liverpool
    MS-Off Ver
    2003
    Posts
    88

    Re: Links do not work once sent via outlook

    hi i got this working now. Brain working slow

    i changed the following
    Cells(1).PasteSpecial xlPasteValues, , False, False
    To
    Cells(1).PasteSpecial xlPasteAll, , False, False
    Sometimes we over look the small things and think its something alot bigger then what it actually is. If you have been working on this thanks for your time

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1