Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Working with word 2000

Status
Not open for further replies.

Haunter

Programmer
Jan 2, 2001
379
US
Ok I have a simple to task to emulate but just am not getting the right calls. I need to open a pre existing word document. emulate the search and replace feature right from the start of the document. This is what I have

private void PrimaryDataPrint_Click(object sender, System.EventArgs e)
{
// Use the open file dialog to choose a word document
if (this.openFileDialog1.ShowDialog() == DialogResult.OK)
{

// set the file name from the open file dialog
object fileName = openFileDialog1.FileName;
object readOnly = false;

object isVisible = true;

// Here is the way to handle parameters you don't care about in .NET
object missing = System.Reflection.Missing.Value;

// Make word visible, so you can see what's happening

WordApp.Visible = true;

// Open the document that was chosen by the dialog
Word.Document aDoc = WordApp.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 isVisible);

// Activate the document so it shows up in front

aDoc.Activate();
// Experimenting starts here


object FindText = "this";
object ReplaceWith = "that";
object Replace = true;
object Forward = true;
object Wrap = false;
object Format = false;
object MatchCase = false;
object MatchWholeWord = false;
object MatchWildCards = false;
object MatchSoundsLike = false;
object MatchAllWordForms = false;

WordApp.Selection.Find.Execute( ref FindText,
ref MatchCase,
ref MatchWholeWord,
ref MatchWildCards,
ref MatchSoundsLike,
ref MatchAllWordForms,
ref Forward,
ref Wrap,
ref Format,
ref ReplaceWith,
ref Replace,
ref missing,
ref missing,
ref missing,
ref missing
);

// Add the copyright text and a line break
WordApp.Selection.TypeText("Some Text");
WordApp.Selection.TypeParagraph();
}


}

//END


Anyone who has some online references to what the methods,objects and parameter to calls for Office mean or how I can access and use them through vs.net please let me know..
Thanks in Advance



haunter@battlestrata.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top