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 best solutions below

0
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