Currently I am developing a project of online exam and I want to read a word file which contains images. I have a code to read word file line by line but I don't know how to read images from word file.
My Code:
word = new Microsoft.Office.Interop.Word.Application();
object miss = System.Reflection.Missing.Value;
OpenFileDialog file = new OpenFileDialog();
if (file.ShowDialog() == DialogResult.OK)
{
object path = file.FileName; //get the path of the file
MessageBox.Show(path.ToString());
object readOnly = true;
Microsoft.Office.Interop.Word.Document docs = word.Documents.Open(ref path,
ref miss,
ref readOnly,
ref miss,
ref miss,
ref miss,
ref miss,
ref miss,
ref miss,
ref miss,
ref miss,
ref miss,
ref miss,
ref miss,
ref miss,
ref miss);
string totaltext = "";
for (int i = 0; i < docs.Paragraphs.Count; i++)
{
totaltext += " \r\n " + docs.Paragraphs[i + 1].Range.Text.ToString();
}
Console.WriteLine(totaltext);
docs.Close();
word.Quit();
}