Click here to Skip to main content
15,902,939 members
Home / Discussions / C#
   

C#

 
GeneralRe: Side TabControl Pin
Carlos H. Perez4-Jun-04 11:12
Carlos H. Perez4-Jun-04 11:12 
GeneralDropDown ComboBox in CompactFramework Pin
renatogostoli4-Jun-04 7:29
renatogostoli4-Jun-04 7:29 
Generalsmtp Pin
kendao4-Jun-04 7:25
kendao4-Jun-04 7:25 
GeneralRe: smtp Pin
Heath Stewart4-Jun-04 9:28
protectorHeath Stewart4-Jun-04 9:28 
GeneralRe: smtp Pin
Vasudevan Deepak Kumar4-Jun-04 23:01
Vasudevan Deepak Kumar4-Jun-04 23:01 
GeneralCatching event when a listview control columnheader is resized.. Pin
Sudhakar Pasupunuri4-Jun-04 6:20
Sudhakar Pasupunuri4-Jun-04 6:20 
GeneralRe: Catching event when a listview control columnheader is resized.. Pin
Heath Stewart4-Jun-04 6:54
protectorHeath Stewart4-Jun-04 6:54 
GeneralOffice Automation - problem with Find object Pin
Matt Casto4-Jun-04 6:05
Matt Casto4-Jun-04 6:05 
I'm trying to get office automation working, and most things work except working with the Find object. For some reason, every time I try to access the Find object (both through Selection or Range) I find that the Find object is a null reference. If I try to add a watch to my Document and debug, when I expand the Selection then the Find object, my debugger crashes. I am running Office 2000. Trying similar code in VB.NET yields similar results.

The following is a simple Console app that I created to test this. It only requires that the "C:\TestFindReplace\TestDoc.doc" is a valid path with a word doc that contains the text ":FULLNAME:" somewhere. Of course, you can change the filename and path to whatever if you want to test this code. Also, you will need to add a reference to the Microsoft Word 9.0 COM object.

<br />
[STAThread] static void Main(string[] args)<br />
{<br />
  Console.Write("Enter the person's name: ");<br />
  string fullName = Console.ReadLine();<br />
  Console.WriteLine();<br />
  FindReplace(fullName);<br />
}<br />
static private void FindReplace(string fullName)<br />
{<br />
  object oFileName = @"C:\TestFindReplace\TestDoc.doc";<br />
  object oNewFileName = @"C:\TestFindReplace\" + fullName + ".doc";<br />
  object oFalse = false;<br />
  object oMissing = Type.Missing;<br />
  object oReplaceAll = Word.WdReplace.wdReplaceAll;<br />
<br />
  Word.Application WordApp = new Word.ApplicationClass();<br />
  Word.Document myDoc = WordApp.Documents.Open(ref oFileName,<br />
    ref oMissing, ref oFalse, ref oMissing, ref oMissing,<br />
    ref oMissing, ref oMissing, ref oMissing, ref oMissing,<br />
    ref oMissing, ref oMissing, ref oFalse);<br />
  try<br />
  {<br />
    myDoc.Application.Selection.Find.Text = ":FULLNAME:";<br />
    myDoc.Application.Selection.Find.Replacement.Text = fullName; <br />
    myDoc.Application.Selection.Find.Execute(ref oMissing,<br />
      ref oMissing, ref oMissing, ref oMissing,<br />
      ref oMissing, ref oMissing, ref oMissing,<br />
      ref oMissing, ref oMissing, ref oMissing,<br />
      ref oReplaceAll, ref oMissing, ref oMissing,<br />
      ref oMissing, ref oMissing);<br />
    myDoc.SaveAs(ref oNewFileName, ref oMissing, ref oMissing, ref oMissing,<br />
      ref oMissing, ref oMissing, ref oMissing, ref oMissing,<br />
      ref oMissing, ref oMissing, ref oMissing);<br />
  }<br />
  finally<br />
  {<br />
    WordApp.Quit(ref oMissing, ref oMissing, ref oMissing);<br />
  }<br />
}<br />


Is anyone getting behavior like this? Does this code work for anyone else?
GeneralRe: Office Automation - problem with Find object Pin
Dave Kreskowiak4-Jun-04 11:01
mveDave Kreskowiak4-Jun-04 11:01 
GeneralRe: Office Automation - problem with Find object Pin
Matt Casto7-Jun-04 2:57
Matt Casto7-Jun-04 2:57 
GeneralRegisterClass equivalent Pin
sjhart4-Jun-04 5:20
sjhart4-Jun-04 5:20 
GeneralRe: RegisterClass equivalent Pin
Heath Stewart4-Jun-04 5:23
protectorHeath Stewart4-Jun-04 5:23 
GeneralRe: RegisterClass equivalent Pin
sjhart4-Jun-04 5:34
sjhart4-Jun-04 5:34 
GeneralRe: RegisterClass equivalent Pin
Heath Stewart4-Jun-04 5:54
protectorHeath Stewart4-Jun-04 5:54 
Questiona syntax question? Pin
BillAnton4-Jun-04 5:14
BillAnton4-Jun-04 5:14 
AnswerRe: a syntax question? Pin
Heath Stewart4-Jun-04 5:21
protectorHeath Stewart4-Jun-04 5:21 
GeneralRe: a syntax question? Pin
Heath Stewart4-Jun-04 9:26
protectorHeath Stewart4-Jun-04 9:26 
GeneralRe: a syntax question? Pin
Dave Kreskowiak4-Jun-04 10:51
mveDave Kreskowiak4-Jun-04 10:51 
GeneralRe: a syntax question? Pin
Heath Stewart4-Jun-04 10:52
protectorHeath Stewart4-Jun-04 10:52 
GeneralClient &amp; Server Pin
IamADotNetGuy4-Jun-04 4:47
IamADotNetGuy4-Jun-04 4:47 
GeneralRe: Client &amp; Server Pin
Dave Kreskowiak4-Jun-04 10:50
mveDave Kreskowiak4-Jun-04 10:50 
GeneralC# refactoring tool Pin
..Hubert..4-Jun-04 1:39
..Hubert..4-Jun-04 1:39 
GeneralRe: C# refactoring tool Pin
Nick Parker4-Jun-04 9:53
protectorNick Parker4-Jun-04 9:53 
GeneralRe: C# refactoring tool Pin
Stefan Troschuetz4-Jun-04 22:32
Stefan Troschuetz4-Jun-04 22:32 
GeneralRe: C# refactoring tool Pin
leppie5-Jun-04 1:15
leppie5-Jun-04 1:15 

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.