P
pRobinson
I have been stuck on this for a few days....
I have created a windows application (ie windows form) which calls to a Word
Doc. and opens the document and extracts text from tables cells.
I'm having problems getting the check box object and extracting the value
ie: if it's checked or not.
Here is an example of what i have so far....
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Reflection;
using System.Windows.Forms;
using Microsoft.Office.Core;
using Microsoft.Office.Interop.Word;
using Microsoft.Office.Tools;
using Microsoft.VisualStudio.Tools.Applications.Runtime;
using Word = Microsoft.Office.Interop.Word;
namespace WordConvert
{
public partial class frmMaster : Form
{
Object oMissing = System.Reflection.Missing.Value;
Object oEndOfDocument = "\\endofdocuemnt";
object fileName = @"C:\MyDoc.DOC";
Word._Application oWord;
Word.Document oDocument;
Word.Table oTable;
Word.CheckBox oCheckBox;
//Word.FormField oCheckBox;
public frmMaster()
{
InitializeComponent();
}
private void btnRunWord_Click(object sender, System.EventArgs e)
{
oWord = new Word.Application();
oWord.Application.Documents.Open(ref fileName,
ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing,
ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing,
ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing);
oDocument = oWord.ActiveDocument;
oTable = oDocument.Tables[1];
lblReference1.Text = oTable.Cell(1, 1).Range.Text.ToString();
lblReference2.Text = oTable.Cell(1, 2).Range.Text.ToString();
******// THIS IS WHERE I'M STUCK*******
if (oDocument.FormFields.get_Item(ref oCheckBox).CheckBox.Value == true)
{
chkTest.Checked = true;
}
}
}
}
Any help would be greatly appreciated. Just heads up I'm opening a word
document FROM a windows FORM and not from within the VS 2005 IDE environment.
I have created a windows application (ie windows form) which calls to a Word
Doc. and opens the document and extracts text from tables cells.
I'm having problems getting the check box object and extracting the value
ie: if it's checked or not.
Here is an example of what i have so far....
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Reflection;
using System.Windows.Forms;
using Microsoft.Office.Core;
using Microsoft.Office.Interop.Word;
using Microsoft.Office.Tools;
using Microsoft.VisualStudio.Tools.Applications.Runtime;
using Word = Microsoft.Office.Interop.Word;
namespace WordConvert
{
public partial class frmMaster : Form
{
Object oMissing = System.Reflection.Missing.Value;
Object oEndOfDocument = "\\endofdocuemnt";
object fileName = @"C:\MyDoc.DOC";
Word._Application oWord;
Word.Document oDocument;
Word.Table oTable;
Word.CheckBox oCheckBox;
//Word.FormField oCheckBox;
public frmMaster()
{
InitializeComponent();
}
private void btnRunWord_Click(object sender, System.EventArgs e)
{
oWord = new Word.Application();
oWord.Application.Documents.Open(ref fileName,
ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing,
ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing,
ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing);
oDocument = oWord.ActiveDocument;
oTable = oDocument.Tables[1];
lblReference1.Text = oTable.Cell(1, 1).Range.Text.ToString();
lblReference2.Text = oTable.Cell(1, 2).Range.Text.ToString();
******// THIS IS WHERE I'M STUCK*******
if (oDocument.FormFields.get_Item(ref oCheckBox).CheckBox.Value == true)
{
chkTest.Checked = true;
}
}
}
}
Any help would be greatly appreciated. Just heads up I'm opening a word
document FROM a windows FORM and not from within the VS 2005 IDE environment.