Click here to Skip to main content
15,881,794 members
Home / Discussions / C#
   

C#

 
GeneralRe: Wireless Sensor Node Simulation Time in C# Pin
Nico Encarnacion12-Mar-13 20:05
Nico Encarnacion12-Mar-13 20:05 
GeneralRe: Wireless Sensor Node Simulation Time in C# Pin
Gerry Schmitz13-Mar-13 12:10
mveGerry Schmitz13-Mar-13 12:10 
QuestionExplicit type-casting of pointer Pin
Flo_897-Mar-13 11:18
Flo_897-Mar-13 11:18 
AnswerRe: Explicit type-casting of pointer Pin
Gerry Schmitz7-Mar-13 12:23
mveGerry Schmitz7-Mar-13 12:23 
GeneralRe: Explicit type-casting of pointer Pin
Flo_897-Mar-13 12:24
Flo_897-Mar-13 12:24 
AnswerRe: Explicit type-casting of pointer Pin
Matt T Heffron7-Mar-13 12:34
professionalMatt T Heffron7-Mar-13 12:34 
AnswerRe: Explicit type-casting of pointer Pin
harold aptroot7-Mar-13 21:57
harold aptroot7-Mar-13 21:57 
QuestionHow to highlight word in word document using C# Pin
Tridip Bhattacharjee7-Mar-13 3:56
professionalTridip Bhattacharjee7-Mar-13 3:56 
i got a routine which said that it will highlight word in word document but it is giving error "Bad variable type. (Exception from HRESULT: 0x80020008 (DISP_E_BADVARTYPE))"

when this below line execute then exception occur and error as above occur.
C#
range.find.highlight()


here is my full code

C#
private static void HighlightText()
        {
            object fileName = "D:\\CVArchievePath\\C0000000001.doc";
            object textToFind = "test1";
            object readOnly = true;
            Word.Application word = new Word.Application();
            Word.Document doc = new Word.Document();
            object missing = Type.Missing;
            try
            {
                doc = word.Documents.Open(ref fileName, ref missing, ref readOnly,
                                          ref missing, ref missing, ref missing,
                                          ref missing, ref missing, ref missing,
                                          ref missing, ref missing, ref missing,
                                          ref missing, ref missing, ref missing,
                                          ref missing);
                doc.Activate();
                
                object matchPhrase = false;
                object matchCase = false;
                object matchPrefix = false;
                object matchSuffix = false;
                object matchWholeWord = false;
                object matchWildcards = false;
                object matchSoundsLike = false;
                object matchAllWordForms = false;
                object matchByte = false;
                object ignoreSpace = false;
                object ignorePunct = false;

                object highlightedColor = Word.WdColor.wdColorGreen;
                object textColor = Word.WdColor.wdColorLightOrange;

                object missingp = false;
                Word.Range range = doc.Range();

                bool highlighted = range.Find.HitHighlight(ref textToFind,
                                                           ref highlightedColor,
                                                           ref textColor,
                                                           ref matchCase,
                                                           ref matchWholeWord,
                                                           ref matchPrefix,
                                                           ref matchSuffix,
                                                           ref matchPhrase,
                                                           ref matchWildcards,
                                                           ref matchSoundsLike,
                                                           ref matchAllWordForms,
                                                           ref matchByte,
                                                           ref missingp,
                                                           ref missingp,
                                                           ref missingp,
                                                           ref missingp,
                                                           ref missingp,
                                                           ref ignoreSpace,
                                                           ref ignorePunct,
                                                           ref missingp);

                System.Diagnostics.Process.Start(fileName.ToString());
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error : " + ex.Message);
                //Console.ReadKey(true);
            }
        }

tbhattacharjee


modified 8-Mar-13 7:45am.

AnswerRe: How to highlight word in word document using C# Pin
Richard MacCutchan7-Mar-13 5:13
mveRichard MacCutchan7-Mar-13 5:13 
GeneralRe: How to highlight word in word document using C# Pin
Tridip Bhattacharjee8-Mar-13 1:46
professionalTridip Bhattacharjee8-Mar-13 1:46 
GeneralRe: How to highlight word in word document using C# Pin
Richard MacCutchan8-Mar-13 2:16
mveRichard MacCutchan8-Mar-13 2:16 
QuestionRe: How to highlight word in word document using C# Pin
Alan N7-Mar-13 5:17
Alan N7-Mar-13 5:17 
AnswerRe: How to highlight word in word document using C# Pin
Tridip Bhattacharjee8-Mar-13 1:47
professionalTridip Bhattacharjee8-Mar-13 1:47 
GeneralRe: How to highlight word in word document using C# Pin
Alan N8-Mar-13 3:12
Alan N8-Mar-13 3:12 
QuestionC# file access Pin
classy_dog7-Mar-13 1:52
classy_dog7-Mar-13 1:52 
AnswerRe: C# file access Pin
Dave Kreskowiak7-Mar-13 2:30
mveDave Kreskowiak7-Mar-13 2:30 
AnswerRe: C# file access Pin
Matt T Heffron7-Mar-13 8:49
professionalMatt T Heffron7-Mar-13 8:49 
QuestionHow to use sql server database into oracle Pin
Arun kumar Gautam7-Mar-13 1:04
Arun kumar Gautam7-Mar-13 1:04 
AnswerRe: How to use sql server database into oracle Pin
Simon_Whale7-Mar-13 1:14
Simon_Whale7-Mar-13 1:14 
AnswerRe: How to use sql server database into oracle Pin
jschell7-Mar-13 8:34
jschell7-Mar-13 8:34 
AnswerRe: How to use sql server database into oracle Pin
Gerry Schmitz7-Mar-13 19:38
mveGerry Schmitz7-Mar-13 19:38 
QuestionRetrieve Mongodb Images using GridFS C# Winforms Pin
ArunRajendran16-Mar-13 19:38
ArunRajendran16-Mar-13 19:38 
AnswerRe: Retrieve Mongodb Images using GridFS C# Winforms Pin
Eddy Vluggen6-Mar-13 22:48
professionalEddy Vluggen6-Mar-13 22:48 
QuestionC# in vb.net in windows base application Pin
Jinal Mistry6-Mar-13 19:30
Jinal Mistry6-Mar-13 19:30 
AnswerRe: C# in vb.net in windows base application Pin
Richard MacCutchan6-Mar-13 22:30
mveRichard MacCutchan6-Mar-13 22:30 

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.