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.
Thread starter Similar threads Forum Replies Date
D Outlook macros to create meeting on shared calendar Outlook VBA and Custom Forms 10
B Cannot run create macros within Outlook 2007 Using Outlook 2
S Create a clickable custom column field Outlook VBA and Custom Forms 0
O Create a custom contact form - questions before messing things up... Outlook VBA and Custom Forms 4
C Can't create Outlook data file Outlook Wishlist 0
L automaticaly create a teams meeting with a sync Using Outlook 0
D Can Exchange Admin Center create a pst for users email/contacts/calendar? Exchange Server Administration 0
S Create A Search Folder That Looks For Message Class? Outlook VBA and Custom Forms 0
F How to create phone number as links in notes of Contacts Using Outlook 2
Nessa Can't create new appointment Using Outlook 1
A Create date folder and move messages daily Outlook VBA and Custom Forms 1
C Create new Message with shared contacts & BCC'ing recipients Outlook VBA and Custom Forms 0
O Multiple email accounts - hesitate to create a new profile Using Outlook 3
G Can't create Folder Groups in Outlook 2013 Using Outlook 0
N Outlook rules don't create a copy for bcc'ed emails Using Outlook 3
F Delete/create/reset Exchange mailbox on Outlook.com Using Outlook.com accounts in Outlook 3
R Can not create folder to store specific emails in in Outlook for Mac Using Outlook 1
W Create Search Folder excluding Specific Email Addresses Using Outlook 5
A Outlook macro to create search folder with mail categories as criteria Outlook VBA and Custom Forms 3
K VBA BeforeItemMove event create rule to always move to its folder. Outlook VBA and Custom Forms 4
JackBlack What tools do you use to create the signature for email? Using Outlook 3
Rupert Dragwater How to create a new email with @outlook.com Using Outlook.com accounts in Outlook 32
F Should a new email account also create new contacts Using Outlook 2
D create an html table in outlook custom form 2010 using vba in MsAccess Outlook VBA and Custom Forms 7
R Outlook add-in to create new contact from an email. Using Outlook 0
Tanja Östrand Outlook 2016 - Create Macro button to add text in Subject Outlook VBA and Custom Forms 1
Q Script to create a pst file for Archiving Using Outlook 1
Jennifer Murphy Can I create a Rule with Or'd conditions? Using Outlook 1
G How do I create a custom pick list in VB for an outlook automated email? Outlook VBA and Custom Forms 1
L Create Custom Form Using Outlook 0
Diane Poremsky Create a Task when a Message is Flagged New Slipstick.com Articles 0
Stilgar Relsik Create a rule to copy text from an email and paste it in the subject line. Using Outlook 1
Diane Poremsky Create a custom field for Outlook messages New Slipstick.com Articles 0
Mark White vba to create a shared mailbox folder Outlook VBA and Custom Forms 3
Diane Poremsky Automatically create a task when sending a message New Slipstick.com Articles 0
Diane Poremsky Create a Custom Numbering Field for Outlook messages New Slipstick.com Articles 0
Diane Poremsky Create a Series of Tasks using VBA New Slipstick.com Articles 0
J create .pst data file for new gmail account Using Outlook.com accounts in Outlook 1
Diane Poremsky Create an Organizational Forms Library New Slipstick.com Articles 0
Diane Poremsky Create an Organizational Forms Library in Exchange 2013 or Office 365 New Slipstick.com Articles 0
Jeanne Goodman Create Printout from Multiple Shared Calendars Outlook VBA and Custom Forms 8
Diane Poremsky Manually create a POP3 account in Outlook 2007 New Slipstick.com Articles 0
T Create Rule For Secondary E-Mail Address In Outlook 2016 Using Outlook 4
B Macro To Create Rule To Export From Certain Folder Email Information in one workbook multiple sheets Outlook VBA and Custom Forms 0
Diane Poremsky Create Appointments Using Spreadsheet Data New Slipstick.com Articles 0
A VBA to create meeting from template from a time slot selected in someone's calendar Outlook VBA and Custom Forms 5
G Create an Appointment at the Contact's Address From Email Outlook VBA and Custom Forms 0
Diane Poremsky Use VBA to create an Outlook Search Folder for Sender New Slipstick.com Articles 0
Diane Poremsky Create a Task from an Email using a Rule New Slipstick.com Articles 0
Diane Poremsky Create Task or Appointment and Insert Selected Text New Slipstick.com Articles 0
Similar threads


















































Top