Click here to Skip to main content
15,894,410 members
Home / Discussions / C#
   

C#

 
GeneralRe: C# how to tell if a file is text Pin
Krazy Programmer29-May-08 21:08
Krazy Programmer29-May-08 21:08 
AnswerRe: C# how to tell if a file is text Pin
leppie29-May-08 22:03
leppie29-May-08 22:03 
AnswerRe: C# how to tell if a file is text Pin
buchstaben29-May-08 22:32
buchstaben29-May-08 22:32 
GeneralRe: C# how to tell if a file is text Pin
darkelv30-May-08 2:10
darkelv30-May-08 2:10 
QuestionThe address of pointer that pass to COM object is not right (only in x64) Pin
RYU^^29-May-08 16:49
RYU^^29-May-08 16:49 
AnswerRe: The address of pointer that pass to COM object is not right (only in x64) Pin
leppie29-May-08 22:17
leppie29-May-08 22:17 
GeneralRe: The address of pointer that pass to COM object is not right (only in x64) Pin
RYU^^6-Jun-08 0:13
RYU^^6-Jun-08 0:13 
QuestionImplementing Word's spell check in C# app Pin
Alex MacDonald29-May-08 11:59
Alex MacDonald29-May-08 11:59 
Before I begin, I'm a C#/.NET newbie. I'm completely familiar with C/C++ and using VS in that context, but you can probably expect me to have made very trivial errors.

Anyway...

I'm trying to implement a spell check into a tool I'm helping to develop -- I suppose the easiest way to do this would be to use the spell check from Word, so I don't have to duplicate any of its functionality.

I'm working in C#, but the article on this site for a VB.net version (http://www.codeproject.com/KB/office/SpellCheckUsingWord.aspx) helped to walk me through writing it up.

However, there are catches! Apparently, all of the tutorials I've checked out are using a different version of Office (11 instead of 12) which keeps me from compiling.

Here's my relevant code...
// open word, create a document, and hide these shenanigans from the user.
ApplicationClass WordApp = new ApplicationClass();
DocumentClass WordDoc = WordApp.Documents.Add();
WordApp.Visible = false;

// copy the text into the word document and spellcheck it
String OldClipboardText = Clipboard.GetText();
Clipboard.SetDataObject(textBox1.Text);
WordDoc.Content.Paste();
WordDoc.Activate();
WordDoc.CheckSpelling();

WordDoc.Content.Copy();
if (Clipboard.GetDataObject.GetDataPresent(DataFormats.Text))
{
    textBox1.Text = CType(Clipboard.GetDataObject.GetData(DataFormats.Text), String);
}

WordDoc.Saved = true;
WordDoc.Close();
WordApp.Quit();

Clipboard.SetDataObject(OldClipboardText);


and here's the compilation log:

------ Build started: Project: StupidSpellcheckSandboxApp, Configuration: Debug Any CPU ------

// BLAH BLAH BLAH, TRIMMIN' OUT USELESS JUNK

C:\Documents and Settings\amacdonald\My Documents\Visual Studio 2008\Projects\StupidSpellcheckSandboxApp\StupidSpellcheckSandboxApp\Form1.cs(27,41): error CS1501: No overload for method 'Add' takes '0' arguments
c:\WINDOWS\assembly\GAC\Microsoft.Office.Interop.Word\12.0.0.0__71e9bce111e9429c\Microsoft.Office.Interop.Word.dll: (Related file)
C:\Documents and Settings\amacdonald\My Documents\Visual Studio 2008\Projects\StupidSpellcheckSandboxApp\StupidSpellcheckSandboxApp\Form1.cs(35,17): error CS1501: No overload for method 'CheckSpelling' takes '0' arguments
c:\WINDOWS\assembly\GAC\Microsoft.Office.Interop.Word\12.0.0.0__71e9bce111e9429c\Microsoft.Office.Interop.Word.dll: (Related file)
C:\Documents and Settings\amacdonald\My Documents\Visual Studio 2008\Projects\StupidSpellcheckSandboxApp\StupidSpellcheckSandboxApp\Form1.cs(38,31): error CS0119: 'System.Windows.Forms.Clipboard.GetDataObject()' is a 'method', which is not valid in the given context
C:\Documents and Settings\amacdonald\My Documents\Visual Studio 2008\Projects\StupidSpellcheckSandboxApp\StupidSpellcheckSandboxApp\Form1.cs(40,37): error CS0103: The name 'CType' does not exist in the current context
C:\Documents and Settings\amacdonald\My Documents\Visual Studio 2008\Projects\StupidSpellcheckSandboxApp\StupidSpellcheckSandboxApp\Form1.cs(40,53): error CS0119: 'System.Windows.Forms.Clipboard.GetDataObject()' is a 'method', which is not valid in the given context
C:\Documents and Settings\amacdonald\My Documents\Visual Studio 2008\Projects\StupidSpellcheckSandboxApp\StupidSpellcheckSandboxApp\Form1.cs(40,94): error CS0118: 'string' is a 'type' but is used like a 'variable'
C:\Documents and Settings\amacdonald\My Documents\Visual Studio 2008\Projects\StupidSpellcheckSandboxApp\StupidSpellcheckSandboxApp\Form1.cs(44,17): error CS1501: No overload for method 'Close' takes '0' arguments
c:\WINDOWS\assembly\GAC\Microsoft.Office.Interop.Word\12.0.0.0__71e9bce111e9429c\Microsoft.Office.Interop.Word.dll: (Related file)
C:\Documents and Settings\amacdonald\My Documents\Visual Studio 2008\Projects\StupidSpellcheckSandboxApp\StupidSpellcheckSandboxApp\Form1.cs(45,17): error CS1501: No overload for method 'Quit' takes '0' arguments
c:\WINDOWS\assembly\GAC\Microsoft.Office.Interop.Word\12.0.0.0__71e9bce111e9429c\Microsoft.Office.Interop.Word.dll: (Related file)

Compile complete -- 8 errors, 0 warnings
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========


Why is VS crying over the number of arguments? All of the MSDN documentation I've read says that the arguments I leave out are optional. I'm rather exasperated, having been Googling this for a while, either to find a less frustrating method of implementing this (and preferably less hackish than copying and pasting it behind the scenes) or to see if somebody else that figured out what's up with the function parameters, but no luck.

Thanks in advance.
AnswerRe: Implementing Word's spell check in C# app Pin
Judah Gabriel Himango29-May-08 13:05
sponsorJudah Gabriel Himango29-May-08 13:05 
AnswerRe: Implementing Word's spell check in C# app Pin
Vasudevan Deepak Kumar29-May-08 18:20
Vasudevan Deepak Kumar29-May-08 18:20 
AnswerRe: Implementing Word's spell check in C# app Pin
buchstaben29-May-08 22:37
buchstaben29-May-08 22:37 
QuestionHow to rename my Solution Name (Vs2005) ? Pin
hdv21229-May-08 11:19
hdv21229-May-08 11:19 
AnswerRe: How to rename my Solution Name (Vs2005) ? Pin
Judah Gabriel Himango29-May-08 12:38
sponsorJudah Gabriel Himango29-May-08 12:38 
QuestionAdding data to a new worksheet in an existing workbook c# Pin
compninja2529-May-08 10:47
compninja2529-May-08 10:47 
AnswerRe: Adding data to a new worksheet in an existing workbook c# Pin
Judah Gabriel Himango29-May-08 12:37
sponsorJudah Gabriel Himango29-May-08 12:37 
GeneralRe: Adding data to a new worksheet in an existing workbook c# Pin
compninja2530-May-08 1:59
compninja2530-May-08 1:59 
GeneralRe: Adding data to a new worksheet in an existing workbook c# Pin
Robert Ernst28-Aug-08 11:34
Robert Ernst28-Aug-08 11:34 
QuestionWPF and C# Help Pin
Tyler Lovejoy29-May-08 10:20
Tyler Lovejoy29-May-08 10:20 
AnswerRe: WPF and C# Help Pin
Judah Gabriel Himango29-May-08 12:34
sponsorJudah Gabriel Himango29-May-08 12:34 
GeneralRe: WPF and C# Help Pin
Tyler Lovejoy30-May-08 2:53
Tyler Lovejoy30-May-08 2:53 
AnswerRe: WPF and C# Help Pin
Bert delaVega30-May-08 5:50
Bert delaVega30-May-08 5:50 
AnswerRe: WPF and C# Help Pin
Tyler Lovejoy2-Jun-08 6:25
Tyler Lovejoy2-Jun-08 6:25 
QuestionAppending Multiple RTF FIles Together for Printout Pin
redfish3429-May-08 9:15
redfish3429-May-08 9:15 
AnswerRe: Appending Multiple RTF FIles Together for Printout Pin
Thomas Stockwell30-May-08 10:43
professionalThomas Stockwell30-May-08 10:43 
QuestionIs it possible to change Intranet Zone to Full Trust thrue code? Pin
Phrone29-May-08 8:40
Phrone29-May-08 8:40 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.