Determining current cursor position in inspector item

  • Thread starter Thread starter Daniel Klann
  • Start date Start date
D

Daniel Klann

Hi people,

I'm working with Outlook XP on Windows XP.

I've added some simple functionality to Outlook by allowing me to insert a
hyperlink to a folder or file into a message. I can browse to the file or
folder using the common dialog and BrowseForFolder API functions and the
hyperlink is added. Here is the procedure for inserting a folder
hyperlink:-

=======================================================================
Sub LinkToFolder()
Dim strHTML As String
Dim MItem As MailItem
Dim strTextToDisplay As String

strHTML = basBrowseForFolder.GetDirectory("Please Select Folder...")


If strHTML = "" Then Exit Sub
strHTML = Replace(strHTML, " ", "%20")
strHTML = "<A HREF=file://" & strHTML
strTextToDisplay = InputBox("What text do you wish to display?")
If strTextToDisplay = "" Then Exit Sub

strHTML = strHTML & ">" & strTextToDisplay & "</a>"

Set MItem = Application.ActiveInspector.CurrentItem

MItem.HTMLBody = strHTML & MItem.HTMLBody

End Sub

=======================================================================

The basBrowseForFolder is just the code from www.j-walk.com . Now, you can
see that
the hyperlink is inserted at the start of the active inspector's item, with
whatever text may already be in the message is appended after the hyperlink.

How can I insert the hyperlink whereever the cursor is in the message,
leaving text before and after the cursor undisturbed E.g. if I was replying
to a message and typed "The reports that you require can be found in this
folder" where the word 'this' would be the hyperlink to the folder in
question. This has had me
confused all afternoon and I'd love it if someone can shed some light.

Thanks for any help!

Daniel
 
Thanks Sue. Using Word may be the way to go.

Regards,
Daniel


If the user has Word as their editor, you can get the cursor position from
Word (ActiveInspector.WordEditor). Otherwise, Outlook provides no way to
determine the cursor position.

--
Sue Mosher, Outlook MVP
Outlook and Exchange solutions at http://www.slipstick.com
Author of
Microsoft Outlook Programming: Jumpstart
for Administrators, Power Users, and Developers
 
Back
Top