General discussion

Locked

Spell Check

By tptbusines_98 ·
Hello,
I am creating an application in MS-Access 97.
I have added an automated process of sending an email through Microsoft
Outlook?
How do I add "spell check" properties to the following code:

Private Sub Form_Load()

Dim objOutlookApp As Outlook.Application
Dim objNameSpace As Outlook.NameSpace
Dim objMail As Outlook.MailItem

'Set the application objects
Set objOutlookApp = Outlook.Application
Set objNameSpace = objOutlookApp.GetNamespace("MAPI")

'Login to Outlook
objNameSpace.Logon

'Set the mail item
Set objMail = objOutlookApp.CreateItem(olMailItem)

'Set properties for the mail item and send mail
With objMail
.BCC = ""
.Subject = "Message Sent from Visual Basic"
.Body = "This message was created by automating Outlook from
VB!"
.Send
End With

'Logoff NameSpace
objNameSpace.Logoff

'Release objects
Set objMail = Nothing
Set objNameSpace = Nothing
Set objOutlookApp = Nothing

End Sub

Charles L. Phillips

This conversation is currently closed to new comments.

1 total post (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

by p7ants In reply to Spell Check

Add this code just before the .send in the with objmail...

'Need to reference Microsoft Word 9.0 object model

Dim oWord As Object
Dim oTmpDoc As Object
Dim lOrigTop As Long

' Create a Word document object...
Set oWord = CreateObject("Word.Application")
Set oTmpDoc = oWord.Documents.Add

' Position Word off screen to avoid having document visible...
lOrigTop = oWord.Top
oWord.WindowState = 0
oWord.Top = -3000

' Assign the text to the document and check spelling...
With oTmpDoc
.Content.Text = objMail.Body
.Activate
.CheckSpelling

' After user has made changes, get text back...
objMail.Body = .Content.Text

' Close the document and exit Word...
.Saved = True
.Close
End With
Set oTmpDoc = Nothing

oWord.Top = lOrigTop
oWord.Quit
Set oWord = Nothing

Back to Software Forum
1 total post (Page 1 of 1)  

Related Discussions

Related Forums