write and format a piece of text in the body using vba

  • Thread starter Screaming Eagles 101
  • Start date
S

Screaming Eagles 101

Hi,

I would like to write a piece of text inside of the message body, using a
certain font,
without losing the rest of the mail.

I tried this using
objItem.Body = "a piece of text" but then I lose all the rest, signature
included.

Using settext and gettext + the clipboard I lose all formatting of the
copied body text.

Is there a way to write a piece of text at the cursor location without
losing all the body text ?
 
S

Sue Mosher [MVP]

If you're using the Outlook editor and not the Word editor, then you have to
use different approaches for HTML and RTF messages. For HTML, use
Inspector.HTMLEditor, as demonstrated in the sample at
http://www.outlookcode.com/codedetail.aspx?id=1358. For RTF, you'd have to
use the SafeInspector object from the third-party Outlook Redemption
library.
 
S

Screaming Eagles 101

HI,

yes, I tried this and it's working. Weird problem : I have a signature a
little formatted,
but using the code the formatting is removed, so this seems not a good
option... :-(

be
nice --------------------------------------------------------------------------------
You have to use a line like this:

objItem.Body = "a piece of text" & objItem.Body

--JP
 
J

JP

Without seeing the rest of your code and knowing what format your
write your messages in, I can't assist any further.

--JP
 
S

Screaming Eagles 101

I made a standard signature in the Outlook client, using some formatting
(bold, italic, different text colors and fonts such as wingdings to get a
mail icon, telephone and fac icon,...)

Standard mail format is RTF, and creating a new mail adds the signature very
well,
with fonts, colors and other formatting perfectly.

When I use this code

Dim objItem As Outlook.MailItem
Set objItem = Application.ActiveInspector.CurrentItem
objItem.Body = "a piece of text" & vbcrlf & objItem.Body

it works, but all formatting, colored text, etc... in the signature is gone,
I get some ugly black text.



--------------------------------------------------------------------------------"JP" <[email protected]> wrote in messageseeing the rest of your code and knowing what format yourwrite your messages in, I can't assist any further.--JPOn Nov 16, 5:47 am, " Screaming Eagles 101"<[email protected]> wrote:> HI,>> yes, I tried this and it's working. Weird problem : I have a signature a> little formatted,> but using the code the formatting is removed, so this seems not a good> option... :-(>> be>nice ---------------------------------------------------------------------------­-----"JP" <[email protected]> wrote in message>> You have to use a line like this:>> objItem.Body = "a piece of text" & objItem.Body>> --JP>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top