run time error 424 in Outlook 2007

S

Soapy

Hi:

I am trying to run a dinky little macro in Outlook 2007. I run it in Word
2007 with no problem, but get a run time error when I try to use it in
Outlook.

I copied it out of my Word macros and pasted it into Outlook

Here's the macro:

Sub Arial()
'
' Arial Macro
'
'
Selection.WholeStory
Selection.Font.Name = "Arial"
Selection.Font.Size = 12
End Sub

anyone have any suggestions as to how I can make this work in Outlook?
thanks.
(e-mail address removed)
 
S

Soapy

Hi Sue:

I am still having trouble. The debug gets stuck on Setobj doc for the Font
name and font size.

Can you help me with this? I can't seem to get past that point. I have
included what I have so far.

I named the macro ARIAL. All I want it to do is select all the text in the
entire document, and then change all the text to Arial size 12 font. What am
I doing wrong?

Sub Arial()
' Arial Macro
'
'get a word selection from the open outlook item
Set objDoc = Application.ActiveInspector.WordEditor
Set objSel = objDoc.Windows(1).Selection
'now do what you want with the Selection
objSel.WholeStory
Set objDoc = Font.Name = "Arial"
Set objSel = Font.Size = "12"
End Sub

thanks!

================================
 
S

Sue Mosher [MVP-Outlook]

objSel is a Selection object. Therefore, once you have objSel, all you have
to do is replace Selection in your original code with objSel.
--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook Programming: Jumpstart
for Administrators, Power Users, and Developers
 
J

Jkoso

Sue,

I am having a similar issue with the below macro in outlook 2007
I get - Compile error: User Defined type not defined on the first line.
Any suggestions?
thx

Sub test()
Dim objDoc As Word.Document
Dim objSel As Word.Selection

On Error Resume Next
' get a Word.Selection from the open Outlook item
Set objDoc = Application.ActiveInspector.WordEditor
Set objSel = objDoc.Windows(1).Selection

' now do what you want with the Selection
objSel.WholeStory
objSel.Font.Name = "Calibri"
objSel.Font.Size = 12

Set objDoc = Nothing
Set objSel = Nothing

End Sub
 
S

Sue Mosher [MVP-Outlook]

Jkoso, you must use the Tools | References command in the Outlook VBA
environment to add a reference to the Microsoft Word library.
 
J

Jkoso

Thanks !
works great

Jkoso said:
Sue,

I am having a similar issue with the below macro in outlook 2007
I get - Compile error: User Defined type not defined on the first line.
Any suggestions?
thx

Sub test()
Dim objDoc As Word.Document
Dim objSel As Word.Selection

On Error Resume Next
' get a Word.Selection from the open Outlook item
Set objDoc = Application.ActiveInspector.WordEditor
Set objSel = objDoc.Windows(1).Selection

' now do what you want with the Selection
objSel.WholeStory
objSel.Font.Name = "Calibri"
objSel.Font.Size = 12

Set objDoc = Nothing
Set objSel = Nothing

End Sub
 

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