Option Explicit Private Declare Function CoAllowSetForegroundWindow Lib "ole32.dll" (ByVal pUnk As Object, ByVal lpvReserved As Long) As Long Private Sub Command1_Click() Dim oWord As Object Dim oTmpDoc As Object Dim lOrigTop As Long ' Create a Word document object Set oWord = CreateObject("Word.Application") CoAllowSetForegroundWindow oWord, 0 Set oTmpDoc = oWord.Documents.Add ' Position Word off screen to avoid having document visible lOrigTop = oWord.Top oWord.WindowState = 0 oWord.Top = -3000 oWord.Visible = True oWord.Activate ' Copy the contents of the text box to the clipboard Text1.SelStart = 0 Text1.SelLength = Len(Text1.Text) Clipboard.Clear Clipboard.SetText Text1.SelText ' Assign the text to the document and check spelling With oTmpDoc .Content.Paste .Activate '.CheckSpelling ' After the user has made changes, use the clipboard to ' transfer the contents back to the text box .Content.Copy Text1.Text = Clipboard.GetText(vbCFText) ' Close the document and exit Word .Saved = True .Close End With Set oTmpDoc = Nothing oWord.Visible = False oWord.Top = lOrigTop oWord.Quit Set oWord = Nothing End Sub
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)