Hi, I did use that link and downloaded the the Word object library. while it compiles but I received an exception "object reference not set to an instance of object" in the if statement. It is for the using the Microsoft Word spell check. this is the code:
using Word = Microsoft.Office.Interop.Word
Johan Koster
if (textBox1.Text.Length > 0) The debugger has highlighted this statement with the error:
"Object reference not set to an instant of object." which I don't quite understand what it means.
Thanks for helping jbattat
M Kuhn
interface mirror
I dont see any error in your code for object initialization.
I would suggest you the following to change;
1.When Application is set to invisible then document should be also invisible.
( i.e in your case for doc1, Object visible=false; )
2. I dont see any usage of this code;
doc1.CheckSpelling(
ref optional, ref optional, ref optional, ref optional,
ref optional, ref optional, ref optional, ref optional, ref optional,
ref optional, ref optional, ref optional);
Because, you are getting error count from the Proofreading object. Better would be comment this code.
3. Before quitting the application it is always recommended to close the all open documents;
object
ObjFalse=false;object ObjMissing=Missing.Value;
doc1.Close(ref ObjFalse, ref ObjMissing, ref ObjMissing);
Dr. Mojo
Hi, I did use that link and downloaded the the Word object library. while it compiles but I received an exception "object reference not set to an instance of object" in the if statement. It is for the using the Microsoft Word spell check. this is the code:
private
void spellToolStripMenuItem_Click(object sender, EventArgs e){
Word.
Application app = new Word.Application(); int errors = 0; if (textBox1.Text.Length > 0){
app.Visible =
false; object template = Missing.Value; object newTemplate = Missing.Value; object documentType = Missing.Value; object visible = true;Word.
_Document doc1 = app.Documents.Add(ref template, ref newTemplate, ref documentType, ref visible);doc1.Words.First.InsertBefore(textBox1.Text);
Word.
ProofreadingErrors spellErrorsColl = doc1.SpellingErrors;errors = spellErrorsColl.Count;
object optional = Missing.Value;doc1.CheckSpelling(
ref optional, ref optional, ref optional, ref optional, ref optional, ref optional, ref optional, ref optional, ref optional, ref optional, ref optional, ref optional);label1.Text = errors +
" errors corrected "; object first = 0; object last = doc1.Characters.Count - 1;textBox1.Text = doc1.Range(
ref first, ref last).Text;}
object saveChanges = false; object originalFormat = Missing.Value; object routeDocument = Missing.Value;app.Quit(
ref saveChanges, ref originalFormat, ref routeDocument);}
Can you assist
jbattat
jankoesp
you have to download the Introp Assamblies. include the reference of word object library after download and installation.
http://www.microsoft.com/downloads/details.aspx familyid=3c9a983a-ac14-4125-8ba0-d36d67e0f4ad&displaylang=en