Hi,
I've got this bit of code off the interweb and everyone and their dog
says it should work. But it doesn't... For some reason the line
wordDoc.ActiveWindow.Selection.Copy() doesn't copy anything into the
clipboard so the line fileContent =
data.GetData(System.Windows.Forms.DataFormats.Text ).ToString() fails
daying data is nothing.
Has anyone else had this problem or am I just special??
Thanks
Gareth
Private Function extractWordFileText(ByVal filename As String) As
String
Dim fileContent As String
Dim wordApp As New Word.ApplicationClass
Dim nullObject As Object = System.Reflection.Missing.Value
Dim wordDoc As Word.Document = wordApp.Documents.Open(filename, _
nullObject, _
nullObject, _
nullObject, _
nullObject, _
nullObject, _
nullObject, _
nullObject, _
nullObject, _
nullObject, _
nullObject, _
nullObject, _
nullObject, _
nullObject, _
nullObject)
wordDoc.ActiveWindow.Selection.WholeStory()
wordDoc.ActiveWindow.Selection.Copy()
Dim data As System.Windows.Forms.IDataObject =
System.Windows.Forms.Clipboard.GetDataObject()
fileContent =
data.GetData(System.Windows.Forms.DataFormats.Text ).ToString()
wordDoc.Close()
End Function