Selecting a word document file using openfiledialog

2.8k views Asked by At

Im getting problem selecting a MS Word document by using OpenFileDialog. When I press open button, it associates some unwanted document to the word application. Somehow I managed to know that Normal.dotm and NormalEmail.dotm are being accessed.I dont know why?

My code for OpenFileDialog is

this.openFileDialog.Filter = "Text Files (.txt)|*.txt|Word Documents (.docx)|*.docx|Word Template (.dotx)|*.dotx|All Files (*.*)|*.*";
openFileDialog.ValidateNames = true;
openFileDialog.FilterIndex = 1;
if (openFileDialog.ShowDialog() == DialogResult.OK)
{
    this.TextBoxTemplate.Text = openFileDialog.FileName;
}
1

There are 1 answers

0
Zeeshan Amber On

Just found the solution. The OpenFileDialog initiates a new instance of word application in its FileOk event if the file preview pane is enabled. So just disable the preview pane and get rid of the glitches. Thanks