Word as Editor with Legault Code

P

puddytat_99

Windows XP
Office XP

Mr. Legault posted a random fortune generator that works wonderfully
for me, but I would like to use Microsoft Word as my email editor. When
I have my options set to use Word, I get errors with this code. It
wants me to use outlook mail as my editor. Would some kindly soul help
me modify the code so that I can use Word as my editor? I'm not very
proficient. See code below:

Option Explicit
Dim WithEvents objInspectors As Inspectors
Dim WithEvents objInspector As Inspector


Private Sub Application_Startup()
Set objInspectors = Application.Inspectors
End Sub


Private Sub Application_Quit()
Set objInspectors = Nothing
Set objInspector = Nothing
End Sub


Private Sub objInspector_Activate()
Dim strFortune As String, intRandomNumber As Integer
Dim objMailItem As Outlook.MailItem


Randomize ' Initialize random-number generator.
intRandomNumber = Int((3 * Rnd) + 1) ' Generate _
random value between 1 and 3.


Select Case intRandomNumber
Case 1
strFortune = "Fortune 1"
Case 2
strFortune = "Fortune 2"
Case 3
strFortune = "Fortune 3"
End Select


Set objMailItem = objInspector.CurrentItem


objMailItem.Body = objMailItem.Body & strFortune
End Sub


Private Sub objInspectors_NewInspector(ByVal Inspector As Inspector)
If Inspector.CurrentItem.Class <> olMail Then Exit Sub
Set objInspector = Inspector
End Sub
 
E

Eric Legault [MVP - Outlook]

Unfortunately, the NewInspector event is not fired if you use Word as the
editor. You'd have to intervene manually to grab the ActiveInspector object
(custom button click or something) and then call the code to generate the
body text.
 

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