I'm sorry, but I may have misinterpreted what you wanted to do. I thought
that you wanted to insert an image you already had and use it to link to
some location with strURL. But now it seems that you want to insert an image
that only exists on the Internet. Is that correct? In general, this is not a
good practice in email messages, because Outlook and many other mail
programs by default will not load content from the Internet, for security
and privacy reasons. Best practice is to embed the image into the message
from a file that already exists locally, as shown in the code I posted.
If you insist on using a web-based image, then you would need to modify the
HTMLBody property of the message to insert an <img> tag at the desired
location, just the same as you would with a web page. The code sample at
http://www.outlookcode.com/codedetail.aspx?id=1358 shows how to insert an
HTML content string into the current cursor position, but I don't know
whether it will work if Word is the email editor. You'll have to try it and
see.
Sue Mosher
"Southern at Heart" <SouthernatHeart> wrote in
message news:14C16A87-4E35-4102-9BFD-F712FEB6883F@microsoft.com...
> I don't understand everything I know about this!
> In Outlook 2003, using Word 2003 as my editor, I click on the new message
> button to start a new email. It won't let me 'customize' the toolbar, but
> I
> see custom buttons up there that I made in Word. So I cut my code out of
> 'ThisOutlookSession' and opened up Word and pasted it in for Normal.dot,
> then
> I added a button on Word's toolbar to run it. I close Word, go back to
> Outlook, click New Email, and now I see my custom button! Hurray, I'm
> getting somewhere. But now, it doesn't work. It seems like I am missing
> the
> part that defines objMsg? How do I do this?
> Also, I don't understand the reference of 'strFile =
> "C:\Pictures\logo.gif"
> because the picture I'm trying to paste is located on the web at strURL
> Thanks for your patience with SouthernAtHeart!
> Here's my code:
> Sub InsertPicture()
> strFile = "C:\Pictures\logo.gif"
> Set objInsp = objMsg.GetInspector
> Set objDoc = objInsp.WordEditor
> Set objSel = objDoc.Windows(1).Selection
> If objMsg.BodyFormat <> olFormatPlain Then
> Set objShape = objSel.InlineShapes.AddPicture _
> (strFile, False, True)
> objDoc.Hyperlinks.Add objShape.Range, strURL
> End If
>
"Sue Mosher [MVP]" <suemvp@gmail.com> wrote in message
news:e1mYnQFmKHA.1652@TK2MSFTNGP05.phx.gbl...
> In that case, you can return a Word.Document using Inspector.WordEditor
> and
> then use Word methods to perform the insertion, something like this, where
> objMsg is the message you want to modify:
> strFile = "C:\Pictures\logo.gif"
> Set objInsp = objMsg.GetInspector
> Set objDoc = objInsp.WordEditor
> Set objSel = objDoc.Windows(1).Selection
> If objMsg.BodyFormat <> olFormatPlain Then
> Set objShape = objSel.InlineShapes.AddPicture _
> (strFile, False, True)
> objDoc.Hyperlinks.Add objShape.Range, strURL
> End If
> This technique would also work in Outlook 2007, which always uses Word as
> the email editor.
> "Southern at Heart" <SouthernatHeart> wrote in
> message news:F957F25C-A831-4BDE-A415-36F86BB1C3CC@microsoft.com...
>
>> I have Outlook 2003, and I use Word 2003 as my email editor...
> >
> >> > Via a custom tool bar button, I want to use vba to insert a picture
> >> > into
> >> > the
> >> > body of my email (not an attachment). The picture's URL is strURL.
> >> > Does
> >> > anyone know how to do this?