tags:

views:

28

answers:

0

Imports System.Runtime.InteropServices

Public Class Form1

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    Dim proc As New Process()

    With proc.StartInfo
        .Arguments = " Acrobe Reader"
        .UseShellExecute = True
        .WindowStyle = ProcessWindowStyle.Maximized
        .WorkingDirectory = "C:\Program Files\Adobe\Reader 9.0\Reader\" '<----- Set Acrobat Install Path
        .FileName = "AcroRd32.exe" '<----- Set Acrobat Exe Name
    End With

    proc.Start()
    proc.Close()
    proc.Dispose()
End Sub


Private Sub SpellOrGrammarCheck(ByVal blnSpellOnly As Boolean)

    Try
        Dim objWord As Object
        Dim objTempDoc As Object
        Dim iData As IDataObject
        If Textbox1.Text = "" Then
            Exit Sub
        End If

        objWord = New WindowsApplication1.Form1()
        objTempDoc = objWord.Documents.Add
        objWord.Visible = False

        objWord.WindowState = 0
        objWord.Top = -3000

        Clipboard.SetDataObject(Textbox1.Text)

        With objTempDoc
            .Content.Paste()
            .Activate()
            If blnSpellOnly Then
                .CheckSpelling()
            Else
                .CheckGrammar()
            End If

            .Content.Copy()
            iData = Clipboard.GetDataObject
            If iData.GetDataPresent(DataFormats.Text) Then
                Textbox1.Text = CType(iData.GetData(DataFormats.Text), _
                    String)
            End If
            .Saved = True
            .Close()
        End With


        objWord.Quit()

        MessageBox.Show("The spelling check is complete.", _
            "Spell Checker", MessageBoxButtons.OK, _
            MessageBoxIcon.Information)


    Catch COMExcep As Runtime.InteropServices.COMException
        MessageBox.Show( _
            "Microsoft Word must be installed for Spell/Grammar Check " _
            & "to run.", "Spell Checker")

    Catch Excep As Exception
        MessageBox.Show("An error has occurred.", "Spell Checker")

    End Try
End Sub

Private Sub btnSpellCheck_Click(ByVal sender As System.Object, _
    ByVal e As System.EventArgs) Handles btnSpellCheck.Click
    SpellOrGrammarCheck(True)
End Sub

Private Sub btnGrammarCheck_Click(ByVal sender As System.Object, _
    ByVal e As System.EventArgs) Handles btnGrammarCheck.Click
    SpellOrGrammarCheck(False)
End Sub

End Class

I have written this code for opening a pdf file and check the spellin mistakes in it.... Its working for opening pdf file and not working for spell ckeck and not showing mistakes also.... plz help me to comple this program.. and help me in writing a code to find the mistakes like sentence case and highlight them