PC Review Forums Newsgroups Microsoft Outlook Microsoft Outlook Program Addins Re: finding cursor.

Reply

Re: finding cursor.

 
Thread Tools Rate Thread
Old 17-07-2003, 06:01 AM   #1
lloyd christopher
Guest
 
Posts: n/a
Default Re: finding cursor.


very cool! i played with this a bunch with limited success. however it
appears to only work if you use the IHTMLDocument and not the mailitem's
HTMLBody member. i have pasted some code at the bottom.

METHOD1 is how i want to do it, HTMLBody seems to be necessary for unrelated
reasons (images in replies get dropped if I don't), but it fails with:
Run-time error '-2147467259 (80004005)':

Method 'createRange' of object 'IHTMLSelectionObject' failed

but if i use METHOD2, it works like a charm. any ideas? thanks alot for
the help Dmitry / Sue.

Private Sub oMail_Open(Cancel As Boolean)
If oMail.Sent = False Then
Dim strDemoHTML As String
Dim objHTMLDocument As IHTMLDocument
Dim objSelection As IHTMLSelectionObject
Dim objTxtRange As IHTMLTxtRange
Dim objHTMLElement As IHTMLElement


strDemoHTML = "<html><body><div
id='myBody'>rawr</div></body></html>"

Set objHTMLDocument = oMail.GetInspector.HTMLEditor

'change this to METHOD2 and it works
GoTo METHOD1

METHOD1:
oMail.HTMLBody = strDemoHTML
GoTo FINISH

METHOD2:
objHTMLDocument.Write strDemoHTML
objHTMLDocument.Close
GoTo FINISH

FINISH:
Set objSelection = objHTMLDocument.Selection
Set objTxtRange = objSelection.createRange
Set objHTMLElement = objHTMLDocument.getElementById("myBody")

objTxtRange.moveToElementText objHTMLElement
objTxtRange.Select

oMail.Display
End If
End Sub

lloyd christopher
SLOW30

"Dmitry Streblechenko" <dmitry@dimastr.com> wrote in message
news:u8xPWB8SDHA.212@TK2MSFTNGP10.phx.gbl...
> You can also find the selection/cursor pos in case of the HTML editor:
> Inspector.HTMLEditor returns IHTMLDocument which you can use to access the
> selection point (IHTMLDocument.Selection object)
>
> Dmitry Streblechenko (MVP)
> http://www.dimastr.com/
> OutlookSpy - Outlook, CDO
> and MAPI Developer Tool
>
>
> "Sue Mosher [MVP]" <suemvp@slipstick.com> wrote in message
> news:OeGF5v4SDHA.1036@TK2MSFTNGP10.phx.gbl...
> The regular Outlook editor provides no information about the insertion
> point. If you are using Word as the editor, you can use Word objects,
> specifically Selection. The other alternative is to automate the Pste
> command.
> --
> 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
> http://www.slipstick.com/books/jumpstart.htm
>
>
>
> "lloyd christopher" <lloydSPAMGOAWAY@slow30.com> wrote in message
> news:uK6Ra.468764$Vi5.12216739@news1.calgary.shaw.ca...
> > yup but I couldnt find a way to do it using the Outlook Object library.

i
> > want to do something similiar to this in my application.
> >
> > Lloyd Evetts
> > SLOW30
> >
> > "Sue Mosher [MVP]" <suemvp@slipstick.com> wrote in message
> > news:eZX4EWvSDHA.2148@TK2MSFTNGP10.phx.gbl...
> > Did you try the Insert | Picture command?
> >
> > "lloyd christopher" <lloydSPAMGOAWAY@slow30.com> wrote in message
> > news:Y2WQa.438894$ro6.10597347@news2.calgary.shaw.ca...
> > > i recently downloaded an outlook plugin which lets you insert

> images/html
> > > into the body of an email, at the same position as the cursor. i

> couldnt
> > > find anything in the outlook documentation about how to do this,

anyone
> > > knwo?

>
>
>



  Reply With Quote
Old 17-07-2003, 04:46 PM   #2
Dmitry Streblechenko
Guest
 
Posts: n/a
Default Re: finding cursor.

I have no idea, you might be better off asking in the IE/DOM newsgroups.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool


"lloyd christopher" <lloydSPAMGOAWAY@slow30.com> wrote in message
news:0ZqRa.475320$Vi5.12343804@news1.calgary.shaw.ca...
> very cool! i played with this a bunch with limited success. however it
> appears to only work if you use the IHTMLDocument and not the mailitem's
> HTMLBody member. i have pasted some code at the bottom.
>
> METHOD1 is how i want to do it, HTMLBody seems to be necessary for

unrelated
> reasons (images in replies get dropped if I don't), but it fails with:
> Run-time error '-2147467259 (80004005)':
>
> Method 'createRange' of object 'IHTMLSelectionObject' failed
>
> but if i use METHOD2, it works like a charm. any ideas? thanks alot for
> the help Dmitry / Sue.
>
> Private Sub oMail_Open(Cancel As Boolean)
> If oMail.Sent = False Then
> Dim strDemoHTML As String
> Dim objHTMLDocument As IHTMLDocument
> Dim objSelection As IHTMLSelectionObject
> Dim objTxtRange As IHTMLTxtRange
> Dim objHTMLElement As IHTMLElement
>
>
> strDemoHTML = "<html><body><div
> id='myBody'>rawr</div></body></html>"
>
> Set objHTMLDocument = oMail.GetInspector.HTMLEditor
>
> 'change this to METHOD2 and it works
> GoTo METHOD1
>
> METHOD1:
> oMail.HTMLBody = strDemoHTML
> GoTo FINISH
>
> METHOD2:
> objHTMLDocument.Write strDemoHTML
> objHTMLDocument.Close
> GoTo FINISH
>
> FINISH:
> Set objSelection = objHTMLDocument.Selection
> Set objTxtRange = objSelection.createRange
> Set objHTMLElement = objHTMLDocument.getElementById("myBody")
>
> objTxtRange.moveToElementText objHTMLElement
> objTxtRange.Select
>
> oMail.Display
> End If
> End Sub
>
> lloyd christopher
> SLOW30
>
> "Dmitry Streblechenko" <dmitry@dimastr.com> wrote in message
> news:u8xPWB8SDHA.212@TK2MSFTNGP10.phx.gbl...
> > You can also find the selection/cursor pos in case of the HTML editor:
> > Inspector.HTMLEditor returns IHTMLDocument which you can use to access

the
> > selection point (IHTMLDocument.Selection object)
> >
> > Dmitry Streblechenko (MVP)
> > http://www.dimastr.com/
> > OutlookSpy - Outlook, CDO
> > and MAPI Developer Tool
> >
> >
> > "Sue Mosher [MVP]" <suemvp@slipstick.com> wrote in message
> > news:OeGF5v4SDHA.1036@TK2MSFTNGP10.phx.gbl...
> > The regular Outlook editor provides no information about the insertion
> > point. If you are using Word as the editor, you can use Word objects,
> > specifically Selection. The other alternative is to automate the Pste
> > command.
> > --
> > 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
> > http://www.slipstick.com/books/jumpstart.htm
> >
> >
> >
> > "lloyd christopher" <lloydSPAMGOAWAY@slow30.com> wrote in message
> > news:uK6Ra.468764$Vi5.12216739@news1.calgary.shaw.ca...
> > > yup but I couldnt find a way to do it using the Outlook Object

library.
> i
> > > want to do something similiar to this in my application.
> > >
> > > Lloyd Evetts
> > > SLOW30
> > >
> > > "Sue Mosher [MVP]" <suemvp@slipstick.com> wrote in message
> > > news:eZX4EWvSDHA.2148@TK2MSFTNGP10.phx.gbl...
> > > Did you try the Insert | Picture command?
> > >
> > > "lloyd christopher" <lloydSPAMGOAWAY@slow30.com> wrote in message
> > > news:Y2WQa.438894$ro6.10597347@news2.calgary.shaw.ca...
> > > > i recently downloaded an outlook plugin which lets you insert

> > images/html
> > > > into the body of an email, at the same position as the cursor. i

> > couldnt
> > > > find anything in the outlook documentation about how to do this,

> anyone
> > > > knwo?

> >
> >
> >

>
>



  Reply With Quote
Reply



Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off