Assigning macro to keyboard in Outlook

R

R.U. Steinberg

I recorded a simple macro in Word 2003 that I assigned to the keyboard as
Alt-V that pastes plain text (as opposed to formatted, RTF, or HTML text).

I want this same keyboard shortcut to work in Outlook. I understand Outlook
does not have a macro recorder so I recorded it in Word.

The macro shows up in Outlook but I do not know how to make it function. I
dragged it to the Outlook toolbar--how do I assign it to the key (Alt-V)?

The code is as follows:

Sub Macro1()
'
' Macro1 Macro
' Macro recorded 3/17/2008
'
Selection.PasteAndFormat (wdPasteDefault)
End Sub
 
K

Ken Slovak - [MVP - Outlook]

You cannot assign a keyboard shortcut to the macro, nor will that code work
in Outlook.

For example, the macro has Selection with no qualifiers. For Outlook that
means an Explorer.Selection, which does not have a PasteAndFormat() method.
That code won't work at all.

Instead, you'd have to get the current selected item or open item, make sure
it's WordMail, instantiate a WordEditor object which is a Document object,
set the selection in the text, etc. It's not as simple as you seem to think.
 
R

R.U. Steinberg

Thanks very much!

Ken Slovak - said:
You cannot assign a keyboard shortcut to the macro, nor will that code work
in Outlook.

For example, the macro has Selection with no qualifiers. For Outlook that
means an Explorer.Selection, which does not have a PasteAndFormat() method.
That code won't work at all.

Instead, you'd have to get the current selected item or open item, make sure
it's WordMail, instantiate a WordEditor object which is a Document object,
set the selection in the text, etc. It's not as simple as you seem to think.
 

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