Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Word.Application() not defined?

Word.Application() not defined?

Scheduled Pinned Locked Moved Visual Basic
helpquestion
5 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Speedular
    wrote on last edited by
    #1

    Hello all I'm trying to include the a Grammer check into my app; one of the approaches that I've come across is using MS.Words' but it seem that I'm facing somedefficulties that I can't figure out;

    mports System.Runtime.InteropServices Public Class Form1 Inherits System.Windows.Forms.Form ' Invokes either the spell or grammar checker. Private Sub SpellOrGrammarCheck(ByVal blnSpellOnly As Boolean) Try ' Create Word and temporary document objects. Dim objWord As Object Dim objTempDoc As Object ' Declare an IDataObject to hold the data returned from the ' clipboard. Dim iData As IDataObject ' If there is no data to spell check, then exit sub here. If TextBox1.Text = "" Then Exit Sub End If objWord = New Word.Application() // My problem is here as it shows that it is not defined objTempDoc = objWord.Documents.Add objWord.Visible = False ' Position Word off the screen...this keeps Word invisible ' throughout. objWord.WindowState = 0 objWord.Top = -3000 ' Copy the contents of the textbox to the clipboard Clipboard.SetDataObject(TextBox1.Text) ' With the temporary document, perform either a spell check or a ' complete ' grammar check, based on user selection. With objTempDoc .Content.Paste() .Activate() If blnSpellOnly Then .CheckSpelling() Else .CheckGrammar() End If ' After user has made changes, use the clipboard to ' transfer the contents back to the text box .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) ' Microsoft Word must be installed. Catch COMExcep As COMException

    D 1 Reply Last reply
    0
    • S Speedular

      Hello all I'm trying to include the a Grammer check into my app; one of the approaches that I've come across is using MS.Words' but it seem that I'm facing somedefficulties that I can't figure out;

      mports System.Runtime.InteropServices Public Class Form1 Inherits System.Windows.Forms.Form ' Invokes either the spell or grammar checker. Private Sub SpellOrGrammarCheck(ByVal blnSpellOnly As Boolean) Try ' Create Word and temporary document objects. Dim objWord As Object Dim objTempDoc As Object ' Declare an IDataObject to hold the data returned from the ' clipboard. Dim iData As IDataObject ' If there is no data to spell check, then exit sub here. If TextBox1.Text = "" Then Exit Sub End If objWord = New Word.Application() // My problem is here as it shows that it is not defined objTempDoc = objWord.Documents.Add objWord.Visible = False ' Position Word off the screen...this keeps Word invisible ' throughout. objWord.WindowState = 0 objWord.Top = -3000 ' Copy the contents of the textbox to the clipboard Clipboard.SetDataObject(TextBox1.Text) ' With the temporary document, perform either a spell check or a ' complete ' grammar check, based on user selection. With objTempDoc .Content.Paste() .Activate() If blnSpellOnly Then .CheckSpelling() Else .CheckGrammar() End If ' After user has made changes, use the clipboard to ' transfer the contents back to the text box .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) ' Microsoft Word must be installed. Catch COMExcep As COMException

      D Offline
      D Offline
      dan sh
      wrote on last edited by
      #2

      Are you getting any error message? I guess you need to use fully qualified names.

      जय हिंद

      S 1 Reply Last reply
      0
      • D dan sh

        Are you getting any error message? I guess you need to use fully qualified names.

        जय हिंद

        S Offline
        S Offline
        Speedular
        wrote on last edited by
        #3

        Yes it is an error message ...

        D 1 Reply Last reply
        0
        • S Speedular

          Yes it is an error message ...

          D Offline
          D Offline
          dan sh
          wrote on last edited by
          #4

          You need to specify the fully qualified name as I had mentioned before ie use

          Microsoft.Office.Interop.Word.Application

          .

          जय हिंद

          S 1 Reply Last reply
          0
          • D dan sh

            You need to specify the fully qualified name as I had mentioned before ie use

            Microsoft.Office.Interop.Word.Application

            .

            जय हिंद

            S Offline
            S Offline
            Speedular
            wrote on last edited by
            #5

            I've done what you have mentioned; I appreciate your help...and now it says on the error message "Error Expected" what does it mean?

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups