A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Create macros in Outlook 2007



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old August 11th 09, 11:36 PM posted to microsoft.public.outlook.program_vba
cte67
external usenet poster
 
Posts: 15
Default Create macros in Outlook 2007

The site
http://turtleflock-ol2007.spaces.liv...E3D8!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.

Ads
  #2  
Old August 11th 09, 11:40 PM posted to microsoft.public.outlook.program_vba
Sue Mosher [MVP][_3_]
external usenet poster
 
Posts: 465
Default Create macros in Outlook 2007

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, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54


"cte67" wrote in message
...
The site
http://turtleflock-ol2007.spaces.liv...E3D8!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.



  #3  
Old August 12th 09, 10:54 AM posted to microsoft.public.outlook.program_vba
cte67
external usenet poster
 
Posts: 15
Default Create macros in Outlook 2007

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, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54


  #4  
Old August 12th 09, 12:56 PM posted to microsoft.public.outlook.program_vba
Sue Mosher [MVP][_3_]
external usenet poster
 
Posts: 465
Default Create macros in Outlook 2007

Use the Tools | References dialog to add a reference to the Microsoft Word
library to your project.

--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54


"cte67" wrote in message
...
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.



  #5  
Old August 13th 09, 12:12 PM posted to microsoft.public.outlook.program_vba
cte67
external usenet poster
 
Posts: 15
Default Create macros in Outlook 2007

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, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54



  #6  
Old August 17th 09, 07:19 PM posted to microsoft.public.outlook.program_vba
Sue Mosher [MVP][_3_]
external usenet poster
 
Posts: 465
Default Create macros in Outlook 2007

"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, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54


"cte67" wrote in message
...

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.



 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
New User Wants to Create Macros in Outlook NeedOutlookMacroHelp Outlook and VBA 1 January 21st 09 03:32 PM
Outlook 2007 and macros Ratzaz Outlook - Installation 1 September 17th 08 10:23 PM
Macros - Word 2007 and Outlook 2007 hunter Outlook and VBA 6 November 9th 07 11:00 PM
How to best imitate using Word macros in Outlook 2007 AMolotkov Outlook - General Queries 3 December 25th 06 04:58 PM
Enabling VBA macros in Outlook 2007 David Hyde Outlook and VBA 2 September 30th 06 10:56 AM


All times are GMT +1. The time now is 08:17 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.