Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Outlook / Programming VBA / September 2005

Tip: Looking for answers? Try searching our database.

Word as Editor with Legault Code

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
puddytat_99@hotmail.com - 15 Sep 2005 22:13 GMT
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
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.