Can't run macro Outlook 2007 that was created in Word 2007

J

jjobin

I have created the following macro in Word 2007. It is designed to take a

number and convert it to a barcode. (note that you have the barcode font

installed for the barcode to appear). If you select a number (highlight) then

run the macro, it will produce the barcode directly under the number.

It works perfect in Word 2007 but I'm wanting it to function in Outlook

2007. The macro does not even appear in the Developer-Macro-Macro Name

section.

I can cut and paste the code into Outlook 2007, VBA, but when I run it I get

an error on the first line of code.

Sub Convert2BarCode()

'

' Convert2BarCode Macro

'

'

Selection.Copy

Selection.Copy

Selection.EndKey Unit:=wdLine

Selection.TypeParagraph

Selection.PasteAndFormat (wdPasteDefault)

Selection.MoveUp Unit:=wdLine, Count:=1

Selection.TypeText Text:="*"

Selection.EndKey Unit:=wdLine

Selection.TypeText Text:="*"

Selection.MoveLeft Unit:=wdCharacter, Count:=17, Extend:=wdExtend

Selection.Font.Name = "SKANDATA C39"

Selection.Font.Size = 24

End Sub
 
S

Sue Mosher [MVP]

Outlook has no idea what Selection refers to in that first line. My article

at

http://turtleflock-ol2007.spaces.live.com/blog/cns!C1013F1F9A99E3D8!579.entry

explains how to return a Word.Selection object from an Outlook message body.

Sue Mosher

"jjobin" <jjobin> wrote in message

news:5CAE563D-8A01-4D91-A1EC-C7488CCEF937@microsoft.com...
> I have created the following macro in Word 2007. It is designed to take a
> number and convert it to a barcode. (note that you have the barcode font
> installed for the barcode to appear). If you select a number (highlight)
> then
> run the macro, it will produce the barcode directly under the number.

> It works perfect in Word 2007 but I'm wanting it to function in Outlook
> 2007. The macro does not even appear in the Developer-Macro-Macro Name
> section.
> I can cut and paste the code into Outlook 2007, VBA, but when I run it I
> get
> an error on the first line of code.
> Sub Convert2BarCode()
> '
> ' Convert2BarCode Macro
> '
> '
> Selection.Copy
> Selection.Copy
> Selection.EndKey Unit:=wdLine
> Selection.TypeParagraph
> Selection.PasteAndFormat (wdPasteDefault)
> Selection.MoveUp Unit:=wdLine, Count:=1
> Selection.TypeText Text:="*"
> Selection.EndKey Unit:=wdLine
> Selection.TypeText Text:="*"
> Selection.MoveLeft Unit:=wdCharacter, Count:=17, Extend:=wdExtend
> Selection.Font.Name = "SKANDATA C39"
> Selection.Font.Size = 24
> End Sub
>
 
Top