Outlook macro issues

G

Guest

Hello all,

Our office uses two Outlook macros when we are editing communications. We
were given the following instructions to set up the macros:

I. Strikeout Macro
1. Open Outlook
2. Go to Tools -> Macro -> Security. Change Security setting to Low.
3. Go to Tools -> Macro -> Visual Basic Editor
4. In the upper left, expat 'Project 1(VbaProject.OTM)' down to
'ThisOutlookSession'
5. In the box that appears, cut and paste the following code:
Public Sub TestProc()
SendKeys "%OF{TAB 3} {TAB 2}RED{ENTER}"
End Sub
6. Now close out of Microsoft Visual Basic to return to Outlook
7. In Outlook, highlight your Inbox and then click on New to make a new
mail.
8. In the new mail screen, go to Tools -> Customize and in the Command
tab, click Macros.
9. Drag the item called Project1.ThisOutlookSession.TestProc up onto the
Toolbar that begins with File and ends with Help. Drag the item to the right
of Help and drop it.
10. Now without closing the customize box, right click on the
Project1.ThisOutlookSession.TestProc that you now have on your toolbar (not
the one in the Customize box)
11. A menu should come up. The third item should be called Name:
12. Delete the name in the box and type in: St&rike.
13. Now close the Customize Box and then close Outlook. When prompted,
click Yes to save changes.
14. The Strikeout macro should now be installed.
15. Open Outlook and check the Strikeout Macro by highlighting some text
and clicking alt+R.

II. Blue Macro
1. Open Outlook
2. Go to Tools -> Macro -> Visual Basic Editor
3. In the upper left, expat 'Project 1(VbaProject.OTM)' down to
'ThisOutlookSession'
4. In the box that appears, cut and paste the following code:
Public Sub TestProc2()
SendKeys "%OF{TAB 5}RB{ENTER}"
End Sub
5. Now close out of Microsoft Visual Basic to return to Outlook
6. In Outlook, highlight your Inbox and then click on New to make a new
mail.
7. In the new mail screen, go to Tools -> Customize and in the Command
tab, click Macros.
8. Drag the item called Project1.ThisOutlookSession.TestProc2 up onto the
Toolbar that begins with File and ends with Strike. Drag the item to the
right of Strike and drop it.
9. Now without closing the customize box, right click on the
Project1.ThisOutlookSession.TestProc2 that you now have on your toolbar (not
the one in the Customize box)
10. A menu should come up. The third item should be called Name:
11. Delete the name in the box and type in: &DBlue.
12. Now close the Customize Box and then close Outlook. When prompted,
click Yes to save changes.
13. The Blue macro should now be installed.
14. Open Outlook and check the Blue Macro by highlighting some text and
clicking alt+D.

We also have a section that states:
Troubleshooting the Strikeout Macro
Problem: When I use my Strikeout Macro, I get a screen that has a General
Tab and a Security Tab.
This behavior usually occurs if it is the first time you have used the
Strikeout Macro since opening Outlook. We don’t have a way to prevent it from
happening. To troubleshoot:
1. Click Cancel
2. You will see that what you highlighted now has the word RED written
there
3. Click CtrI + Z to Undo. You should now have the sentence you wanted
to Strikeout highlighted again.
4. Try the Macro again. It should work this time.

We've gone through these steps several times on separate machines, but
always encounter the same problem: When we highlight the text and click the
button or type alt+D/R, we are only given the text "RED" or "RB" instead of
the red stricken out text or the blue highlighted text.

I have uploaded two images from a user with working macros.
The macros in use: http://www.flibbertigibbet.org/macros1.png
VBA screenshot: http://www.flibbertigibbet.org/macros2.png

The person who created the macros is no longer employed with us, so we have
no idea what we should do.

Thank you in advance for your assistance.


-s
 
S

Sue Mosher [MVP-Outlook]

Maybe it's just too late at night for me, but I'm not entirely clear on what the purpose of these macros is.

That aside, using SendKeys is the worst possible way to build an Outlook macro. If you want to build a macro that is actually understandable and supportable, we need to know what version of Outlook you're using and whether you're using Word or Outlook as the email editor.

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
G

Guest

Dear Ms Mosher,

We proofread e-mails for non-native speakers before they send the e-mails
out. (They forward an email to us, we proofread and send it back to them,
they send the email to their customers.) The strikeout is to indicate what is
to be deleted or changed; the blue is to indicate what it is to be changed
to. The macros in use are shown in macros1.png as linked in the original
message.

I did not create these macros and therefore have no idea which is the best
way to create them. I am merely the one assigned to question why they do not
work.

Outlook 2003 is being used by all users; to the best of my knowledge,
Outlook is also being used as the e-mail editor.

-s
 
S

Sue Mosher [MVP-Outlook]

Are the messages in HTML or rich-text format? It matters, because the methods available to format text are different. (See http://www.outlookcode.com/d/formatmsg.htm )

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
G

Guest

The messages are mainly in HTML. I did a test with those in rich text and the
macros seemed to work, but we're all supposed to use HTML formatting.
 
S

Sue Mosher [MVP-Outlook]

Here are two macros that will perform font changes on selected text in HTML-format messages using the Outlook editor. One makes the selected text blue. The other makes it red and strikethrough. Note that you must use Tools | References to add a reference in the Outlook VBA project to the Microsoft HTML Object Library.

You can add them to the toolbar using the same technique you used with your earlier macros.

Sub MarkHTMLBlue()
Dim msg As Outlook.MailItem
Dim insp As Outlook.Inspector
' need reference to Microsoft HTML Object Library
' at c:\windows\system32\mshtml.tlb
Dim hed As MSHTML.HTMLDocument
Dim rng As MSHTML.IHTMLTxtRange

Set insp = Application.ActiveInspector
If insp.CurrentItem.Class = olMail Then
Set msg = insp.CurrentItem
If insp.EditorType = olEditorHTML Then
Set hed = msg.GetInspector.HTMLEditor
Set rng = hed.Selection.createRange
rng.pasteHTML "<font color=#0000FF>" & _
rng.Text & "</font>"
End If
End If
Set insp = Nothing
Set rng = Nothing
Set hed = Nothing
Set msg = Nothing
End Sub

Sub MarkHTMLRedStrikethrough()
Dim msg As Outlook.MailItem
Dim insp As Outlook.Inspector
' need reference to Microsoft HTML Object Library
' at c:\windows\system32\mshtml.tlb
Dim hed As MSHTML.HTMLDocument
Dim rng As MSHTML.IHTMLTxtRange

Set insp = Application.ActiveInspector
If insp.CurrentItem.Class = olMail Then
Set msg = insp.CurrentItem
If insp.EditorType = olEditorHTML Then
Set hed = msg.GetInspector.HTMLEditor
Set rng = hed.Selection.createRange
rng.pasteHTML "<font color=#FF0000><strike>" & _
rng.Text & "</strike></font>"
End If
End If
Set insp = Nothing
Set rng = Nothing
Set hed = Nothing
Set msg = Nothing
End Sub

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 

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