Insert picture via code?

  • Thread starter Thread starter Mark. S.
  • Start date Start date
M

Mark. S.

In the compose email form... Is it possible to emulate
the Insert|Picture menu command in code, but without
dialog?
 
Thank you for your response.

I had tried that previously but that method uses a round
about of saving the email message to get the entryID then
reopens it to insert the image, and it is not completely
free of bugs, etc.

And, it does not insert the image at the insertion point
where the cursor is. It simply replaces the entire
 
The idea is that your code would provide the full HTML-tagged content for
the entire message (or as much of it as you want to build programmatically.)
You can get the HTMLEditor object and use its properties to get the
insertion point using the HTML.selection property.

--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
I'm wondering how does one use HTMLdoc.Selection to
insert either text or an html object? (can't seem to find
any examples showing actually inserting into the html
document using html document object model)

This is what I have so far:

Dim myHTML As MSHTML.HTMLDocument
Set myHTML = ActiveInspector.HTMLEditor
' ???
' here I would like to insert my own arbitrary html/text
' i.e. <img src="mypath/myfile.gif" border=0>

Is there a subroutine to insert using myHTML.Selection?
 
I figured it out using...

ActiveInspector.HTMLEditor.execCommand("InsertImage",
False, "C:\myPath\myImage.gif")
 
Well I can insert images into the Inspector message using:

Dim H As MSHTML.HTMLDocument
Set H = ActiveInspector.HTMLEditor
H.execCommand("InsertImage", False, PATH)

I'm inserting images into the HTML message body in
response to a user click on a floating toolbar.

My problem now is that when an image is inserted, it
remains selected (with resizing handles). The next click
on the toolbar, the previously inserted image is
overwritten.

So basically, what I need is the HTML object model
equivalent of the user pressing the "right-arrow" key...
Translation: Moving the insertion point to just after
the inserted image and able to insert additional images
or text without having to click the body of the message.

My current work-around is:

Call ActiveInspector.HTMLEditor.focus
SendKeys "{RIGHT}"

Which seems to work but, then there is issue of setting
the focus. I would like to accomplish this using the
HTML object model.

I have tried:

1) execCommand("Unselect",False) which does not
completed unselect the just inserted image.

2) H.Selection.empty which completely unselects the
inserted image, but the new insertion point is
indeterminant so the next click on the image toolbar can
not insert anything.

I hope this explanation was not too long... and that
someone can point in the right direction.
 
Back
Top