Create macros in Outlook 2007

Status
Not open for further replies.
C

cte67

The site

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

gives a nice clear description of how to create a macro in Outlook 2007. What

I tried is:

Sub Blue()

Dim objDoc As Word.Document

Dim objSelection As Word.Selection

On Error Resume Next

Set objDoc = Application.ActiveInspector.WordEditor

Set objSelection = objDoc.Windows(1).Selection

objSelection.Font.Color = wdColorBlue

Set objSelection = Nothing

Set objDoc = Nothing

End Sub

Unfortunately, this does not work. I am using Outlook 2007, and have the

latest updates (12.0.6504.5000) SP2 MSO (12.0.6425.1000) ... am running

WinXP, Service Pack 3.
 
S

Sue Mosher [MVP]

What specifically doesn't work? Do you have an item open with some text

selected? What happens if you comment out the On Error Resume Next statement

and then step through the code in the debugger? Does any VBA code run at

all?

Sue Mosher

"cte67" <cte67> wrote in message

news:91F46BC5-E0AF-4BFF-A96A-E5CD17C88C84@microsoft.com...
> The site
> http://turtleflock-ol2007.spaces.live.com/blog/cns!C1013F1F9A99E3D8!579.entry
> gives a nice clear description of how to create a macro in Outlook 2007.
> What
> I tried is:

> Sub Blue()
> Dim objDoc As Word.Document
> Dim objSelection As Word.Selection
> On Error Resume Next
> Set objDoc = Application.ActiveInspector.WordEditor
> Set objSelection = objDoc.Windows(1).Selection
> objSelection.Font.Color = wdColorBlue
> Set objSelection = Nothing
> Set objDoc = Nothing
> End Sub

> Unfortunately, this does not work. I am using Outlook 2007, and have the
> latest updates (12.0.6504.5000) SP2 MSO (12.0.6425.1000) ... am running
> WinXP, Service Pack 3.
>
 
C

cte67

I get the msg, "Compile error: User-defined type not defined", on the "Dim

objDoc As Word.Document" line. No change if I comment out the "On Error

Resume Next" line. Am unable to step through the code in the debugger.

"Sue Mosher [MVP]" wrote:
> What specifically doesn't work? Do you have an item open with some text
> selected? What happens if you comment out the On Error Resume Next statement
> and then step through the code in the debugger? Does any VBA code run at
> all?

> > Sue Mosher
> > >
 
S

Sue Mosher [MVP]

Use the Tools | References dialog to add a reference to the Microsoft Word

library to your project.

Sue Mosher

"cte67" <cte67> wrote in message

news:2D5DD7FF-2295-49A6-87A5-BC65E103F861@microsoft.com...
> I get the msg, "Compile error: User-defined type not defined", on the "Dim
> objDoc As Word.Document" line. No change if I comment out the "On Error
> Resume Next" line. Am unable to step through the code in the debugger.
 
C

cte67

I found it under VB. It works now! Thanks!

Under Macro Security, I set "Warnings for all Macros". After the macro is

displayed, I do a "File -> Save". However, after I close Outlook and

restart, it always asks about enabling macros when I try to run the macro.

I did run SelfCert.exe ... gave it the name Macros. No difference ... still

asks about enabling macros after I restart Outlook.

"Sue Mosher [MVP]" wrote:
> Use the Tools | References dialog to add a reference to the Microsoft Word
> library to your project.

> > Sue Mosher
> > >
 
S

Sue Mosher [MVP]

"Warnings for All Macros" does exactly what it says -- warns you regardless

of whether the project has been digitally signed. Try using Tools | Digital

Signature to sign the project, then set macro security to "Warn for signed

macros."

Sue Mosher

"cte67" <cte67> wrote in message

news:1BDAB8FF-7DD5-45E3-B45C-19648BFA5EC4@microsoft.com...

> Under Macro Security, I set "Warnings for all Macros". After the macro is
> displayed, I do a "File -> Save". However, after I close Outlook and
> restart, it always asks about enabling macros when I try to run the macro.

> I did run SelfCert.exe ... gave it the name Macros. No difference ...
> still
> asks about enabling macros after I restart Outlook.
 
Status
Not open for further replies.
Top