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
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