TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Josephat Moseti
NA
6
606
Three button click events in c# accessing the same docx
Jul 24 2017 9:41 AM
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) { }
}
Reply
Answers (
1
)
How to upload audio file to server after recording audio
Add a condition