home *** CD-ROM | disk | FTP | other *** search
/ Mastering Visual Basic 6 / mastvb6.iso / ch_code / ch14 / spelldoc / docform.frm (.txt) next >
Encoding:
Visual Basic Form  |  1996-05-16  |  3.9 KB  |  119 lines

  1. VERSION 5.00
  2. Begin VB.Form DocumentForm 
  3.    Caption         =   "SpellDoc Project"
  4.    ClientHeight    =   6705
  5.    ClientLeft      =   60
  6.    ClientTop       =   345
  7.    ClientWidth     =   9675
  8.    LinkTopic       =   "Form1"
  9.    ScaleHeight     =   6705
  10.    ScaleWidth      =   9675
  11.    StartUpPosition =   3  'Windows Default
  12.    Begin VB.CommandButton Command2 
  13.       Caption         =   "E X I T"
  14.       BeginProperty Font 
  15.          Name            =   "Verdana"
  16.          Size            =   9.75
  17.          Charset         =   0
  18.          Weight          =   700
  19.          Underline       =   0   'False
  20.          Italic          =   0   'False
  21.          Strikethrough   =   0   'False
  22.       EndProperty
  23.       Height          =   510
  24.       Left            =   6960
  25.       TabIndex        =   2
  26.       Top             =   6090
  27.       Width           =   2625
  28.    End
  29.    Begin VB.CommandButton Command1 
  30.       Caption         =   "Spell Check Document"
  31.       BeginProperty Font 
  32.          Name            =   "Verdana"
  33.          Size            =   9.75
  34.          Charset         =   0
  35.          Weight          =   700
  36.          Underline       =   0   'False
  37.          Italic          =   0   'False
  38.          Strikethrough   =   0   'False
  39.       EndProperty
  40.       Height          =   510
  41.       Left            =   4200
  42.       TabIndex        =   1
  43.       Top             =   6090
  44.       Width           =   2625
  45.    End
  46.    Begin VB.TextBox Text1 
  47.       BeginProperty Font 
  48.          Name            =   "Verdana"
  49.          Size            =   9
  50.          Charset         =   0
  51.          Weight          =   400
  52.          Underline       =   0   'False
  53.          Italic          =   0   'False
  54.          Strikethrough   =   0   'False
  55.       EndProperty
  56.       Height          =   5730
  57.       Left            =   105
  58.       MultiLine       =   -1  'True
  59.       ScrollBars      =   2  'Vertical
  60.       TabIndex        =   0
  61.       Text            =   "DocForm.frx":0000
  62.       Top             =   225
  63.       Width           =   9480
  64.    End
  65. Attribute VB_Name = "DocumentForm"
  66. Attribute VB_GlobalNameSpace = False
  67. Attribute VB_Creatable = False
  68. Attribute VB_PredeclaredId = True
  69. Attribute VB_Exposed = False
  70. '  ******************************
  71. '  ******************************
  72. '  ** MASTERING VB6            **
  73. '  ** by Evangelos Petroutos   **
  74. '  ** SYBEX, 1998              **
  75. '  ******************************
  76. '  ******************************
  77. Dim NewInstance As Boolean
  78. Private Sub Command1_Click()
  79. Dim DRange As Range
  80.     Me.Caption = "starting word ..."
  81.     On Error Resume Next
  82.     Set AppWord = GetObject(, "Word.Application")
  83.     If AppWord Is Nothing Then
  84.         Set AppWord = CreateObject("Word.Application")
  85.         If AppWord Is Nothing Then
  86.             MsgBox "Could not start Word. Application will end"
  87.             End
  88.         Else
  89.             NewInstance = True
  90.         End If
  91.     Else
  92.         NewInstance = False
  93.     End If
  94. On Error GoTo ErrorHandler
  95.     AppWord.Documents.Add
  96.     Me.Caption = "checking words..."
  97.     Set DRange = AppWord.ActiveDocument.Range
  98.     DRange.InsertAfter Text1.Text
  99.     Set SpellCollection = DRange.SpellingErrors
  100.     If SpellCollection.Count > 0 Then
  101.         SuggestionsForm.List1.Clear
  102.         SuggestionsForm.List2.Clear
  103.         For iWord = 1 To SpellCollection.Count
  104.             SuggestionsForm!List1.AddItem SpellCollection.Item(iWord)
  105.             If SuggestionsForm!List1.List(SuggestionsForm!List1.NewIndex) = SuggestionsForm!List1.List(SuggestionsForm!List1.NewIndex + 1) Then
  106.                 SuggestionsForm!List1.RemoveItem SuggestionsForm!List1.NewIndex
  107.             End If
  108.         Next
  109.     End If
  110.     Me.Caption = "Word VBA Example"
  111.     SuggestionsForm.Show
  112.     Exit Sub
  113. ErrorHandler:
  114.     MsgBox "The following error occured during the document's spelling" & vbCrLf & Err.Description
  115. End Sub
  116. Private Sub Command2_Click()
  117.     End
  118. End Sub
  119.