Results 1 to 1 of 1

Thread: Insert hyperlink in email from Outlook 2000

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Apr 2005
    Posts
    17

    Insert hyperlink in email from Outlook 2000

    I found some code on the net that allowed me to send, from an MS Access DB, an email containing a hyperlink using Outlook. The code for creating the hyperlink works in Outlook 2003 but not in Outlook 2000. I can send emails fine via either version of Outlook but the hyperlinks only work in Outlook 2003.

    Below is the code i found on the net.
    Code:
    Dim outMail As Object
    Dim outApp As Object
    Dim outInsp As Object
    Dim objWordDoc As Object
    Dim objSel As Object
           
    Set outApp = CreateObject("Outlook.Application")
    outApp.Session.Logon
    Set outMail = outApp.CreateItem(0)
    outMail.to = "x@x.com "    
    Set outInsp = outMail.GetInspector
    Set objWordDoc = outInsp.WordEditor
    Set objSel = objWordDoc.Windows(1).Selection
    If outMail.BodyFormat <> 1 Then
          objWordDoc.Range.Text = objWordDoc.Range.Text & vbCrLf
          objSel.MoveDown Unit:=5, Count:=1
          objWordDoc.Hyperlinks.Add objSel.Range, "\\server\folder\"
    Else
          objSel.InsertAfter "\\server\folder\"
    End If
    outMail.Display
    The error comes at the line: Set objSel = objWordDoc.Windows(1).Selection and i get the error "the requested member of the collection does not exist." So i looked at the Word Document object named objWordDoc in the debugger and see that its windows collection is empty. I try the same line of code on a PC with outlook 2003 and the same object's window collection has a count of 1. I can't figure out why the windows collection count is zero when using outlook 2000. I set the PC's outlook settings to use Word as the default email editor and tried all 3 mail formats. I've also tried using the following
    Code:
    outMail.body = "<br><a href=" & Chr(34) & "File://" & _
    Replace(strPicPath, " ", "%20") & "></a><br>"
    But this also only works in outlook 2003

    Lastly I used the macro recorder in outlook 2000 to see how it inserts hyperlinks and it recorded this:
    Code:
    ActiveDocument.Hyperlinks.Add Anchor:=Selection.Range, _ 
    Address:="\\server\folder\"
    This appears to be the same process used in the code at the begining of this post But I'm not very familiar with MS Word VBA coding and have been unsuccessful trying to get both the ActiveDocument object as well as the Selection.Range for the Add method parameter.

    Does anyone know how to create an outlook 2000 email with a hyperlink?
    Last edited by chshiba; Oct 21st, 2008 at 04:01 PM.

Posting Permissions

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



Click Here to Expand Forum to Full Width