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
Eric Legault [MVP - Outlook] - 16 Sep 2005 17:38 GMT
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.

Signature
Eric Legault (Outlook MVP, MCDBA, old school WOSA MCSD, B.A.)
Try Picture Attachments Wizard - http://www.collaborativeinnovations.ca
Blog: http://blogs.officezealot.com/legault/
> Windows XP
> Office XP
[quoted text clipped - 45 lines]
> Set objInspector = Inspector
> End Sub