Tech
Forums
Jobs
Books
Events
Interviews
Live
More
Learn
Training
Career
Members
Videos
News
Blogs
Post
An Article
A Blog
A Video
An Ebook
An Interview Question
Register
Login
1
Reply
Three button click events in c# accessing the same docx
Josephat Moseti
7 years ago
243
Reply
How do I write my code for three buttons on a user form such that:
button 7 loads a word document and opens it,
button 2 is a find button that searches the open document also highlight found matches one after the other as the user chooses which ones to replace,
button 3 is a replace button that does the replacement while the document is open and visible to the user.
Here is what I have so far but I'm unable to get the other two buttons "button 2" and "button 3" to work without the word app opening over and over every time I hit the find button or the replace button.
here is what I have so far:
private
void
button7_Click(
object
sender, EventArgs e)
{
if
(of.ShowDialog() == DialogResult.OK)
{
textBox7.Text = of.FileName;
object
fileName = Path.Combine(System.Windows.Forms.Application.StartupPath, of.FileName);
Microsoft.Office.Interop.Word.Application wordApp1 =
new
Microsoft.Office.Interop.Word.Application { Visible =
true
};
Microsoft.Office.Interop.Word.Document aDoc = wordApp1.Documents.Open(
ref
fileName, ReadOnly:
false
, Visible:
true
);
Microsoft.Office.Interop.Word.Find fnd = wordApp1.ActiveWindow.Selection.Find;
}
}
private
void
button2_Click(
object
sender, EventArgs e) { }
public
void
button3_Click(
object
sender, EventArgs e) { }
private
void
comboBox3_SelectedIndexChanged(
object
sender, EventArgs e) { }
}
Post
Reset
Cancel
Answers (
1
)
Next Recommended Forum
How to upload audio file to server after recording audio
Add a condition