Outlook Macro - TypeText

G

Guest

Hello!

I need to write a simple macro for Outlook 2007.

I would like it to simply insert several lines of text in the active message
window.

In Outlook/Word 2003, I used the selection.typetext command. What would I
use in Outlook 2007?

If it matters, the messages are (and need to be) plain text.

Thanks in advance!

Kind Regards,
 
S

Sue Mosher [MVP-Outlook]

You should be able to use the same technique in Outlook 2007, since Word is always the editor.

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
G

Guest

Hello!

Thanks for the reply.

Here was my previous code:

~~~~~~~~~
Sub InsertText()
Selection.TypeText Text:="Hello!"
End Sub
~~~~~~~~~

However, VBA does not now recognize the 'application' object, and I get an
error message "Object Required"

Thank you,
 
S

Sue Mosher [MVP-Outlook]

Your previous code was apparently a Word macro, not an Outlook macro. In an Outlook macro, you must first return a Word.Document object from the current item. For example:

Set objDoc = Application.ActiveInspector.WordEditor
Set objSel = objDoc.Windows(1).Selection
objSel.TypeText Text:="Hello!"

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 

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