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

Status
Not open for further replies.
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
>
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
L Outlook 2007 Macro to Run a Script From a Contact Form Using Outlook 41
Z Trigger macro to run after a new mail is received in Outlook? Using Outlook 3
D Create a macro in Outlook to run a rule Outlook VBA and Custom Forms 32
M Run external program from Outlook VBA macro Outlook VBA and Custom Forms 5
Dave A Run macro on existing appointment when it changes Outlook VBA and Custom Forms 1
O Run macro automatically at sending an email Using Outlook 11
S VBA Macro - Run-time error '424': object required - Help Please Outlook VBA and Custom Forms 3
B Can't run macro from QAT when emailing from Acrobat Outlook VBA and Custom Forms 0
P Vba script including macro appears in rules but wont run Outlook VBA and Custom Forms 6
Hudas Run Macro when an Email is received Using Outlook 4
D Trigger macro to run when selected email is opened Using Outlook 3
J Macro to run on Open Outlook VBA and Custom Forms 2
B Run a macro Outlook VBA and Custom Forms 1
K Macro to Run Rules Outlook VBA and Custom Forms 5
E Having some trouble with a run-a-script rule (moving mail based on file type) Outlook VBA and Custom Forms 5
C Auto Run VBA Code on new email Outlook VBA and Custom Forms 1
Aussie Rules Run a Script on an Incoming Email OK and then the Email reverts Outlook VBA and Custom Forms 0
A Apply Selected Emails to outlook rules and Run Rules Using Outlook 5
B VBScript doesn't run on Recipient Email Outlook VBA and Custom Forms 2
A Run-time error '430' on certain emails when trying to set "Outlook.mailitem" as "ActiveExplorer.Selection.Item" Outlook VBA and Custom Forms 2
S Outlook Custom Form Scripting only working when clicking on "Run this form" Outlook VBA and Custom Forms 2
Y Outlook 2013 Run A Script Outlook VBA and Custom Forms 4
O Outlook 2016 This rule will only run when you check your email in Outlook.... Using Outlook 4
B run scripts Using Outlook 1
A Run time error 424. object required in outlook 2013 Outlook VBA and Custom Forms 10
P errors appear every time I run SCANPST Using Outlook 3
B Outlook rule run a Script doesn't work Outlook VBA and Custom Forms 1
B Wanting to run a script that will filter any body that has a russian link in it. Outlook VBA and Custom Forms 5
P Run Time Error 91 when linking contact to task in VBA Outlook VBA and Custom Forms 1
O Having rules run on old mails noved to inbox Outlook VBA and Custom Forms 8
Bri the Tech Guy Registry Tweak to make "Run a Script" Action Available Outlook VBA and Custom Forms 2
Bri the Tech Guy Run Script rule not running for newly arriving messages Outlook VBA and Custom Forms 25
J Custom form code doesn't run Outlook VBA and Custom Forms 2
J VBA Run When Reply Outlook VBA and Custom Forms 4
Vijay Error in rule- Run a script Using Outlook 1
Vijay Run script doesn't work in outlook Using Outlook 1
O VBA to Run Font Change on Outlook Startup Outlook VBA and Custom Forms 4
D Creating an outlook session from Access vba but run silently. With A specific profile Outlook VBA and Custom Forms 1
Diane Poremsky Run a Script Rule: Send a New Message when a Message Arrives New Slipstick.com Articles 2
Diane Poremsky Using Scanpst in Outlook Click to Run New Slipstick.com Articles 0
oliv- How to Run a Script IN AN ADDIN with Outlook's Rules and Alerts Outlook VBA and Custom Forms 2
L Run a Script Rule doesn't work Using Outlook 5
J Outlook 2010 VBScript editor does not run code at all Outlook VBA and Custom Forms 0
X Outlook script to run excel data Outlook VBA and Custom Forms 1
D How to Run a Report Based on Age of Inbox Items Outlook VBA and Custom Forms 0
D RUN SCRIPT WHEN OUTLOOK IS CLOSE Outlook VBA and Custom Forms 1
L Cannot run script from rule Outlook VBA and Custom Forms 7
M Office 365 Click to run BCM (Business Contact Manager) 0
O modify vba to run it as script rule Outlook VBA and Custom Forms 8
D Must now "View on Facebook" for Mentions/Comments-Outlook 2013 click-to-run Using Outlook 2

Similar threads

Top