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.ActiveW indow.Selection .Copy() doesn't copy anything into the
clipboard so the line fileContent =
data.GetData(Sy stem.Windows.Fo rms.DataFormats .Text).ToString () fails
daying data is nothing.
Has anyone else had this problem or am I just special??
Thanks
Gareth
Private Function extractWordFile Text(ByVal filename As String) As
String
Dim fileContent As String
Dim wordApp As New Word.Applicatio nClass
Dim nullObject As Object = System.Reflecti on.Missing.Valu e
Dim wordDoc As Word.Document = wordApp.Documen ts.Open(filenam e, _
nullObject, _
nullObject, _
nullObject, _
nullObject, _
nullObject, _
nullObject, _
nullObject, _
nullObject, _
nullObject, _
nullObject, _
nullObject, _
nullObject, _
nullObject, _
nullObject)
wordDoc.ActiveW indow.Selection .WholeStory()
wordDoc.ActiveW indow.Selection .Copy()
Dim data As System.Windows. Forms.IDataObje ct =
System.Windows. Forms.Clipboard .GetDataObject( )
fileContent =
data.GetData(Sy stem.Windows.Fo rms.DataFormats .Text).ToString ()
wordDoc.Close()
End Function
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.ActiveW indow.Selection .Copy() doesn't copy anything into the
clipboard so the line fileContent =
data.GetData(Sy stem.Windows.Fo rms.DataFormats .Text).ToString () fails
daying data is nothing.
Has anyone else had this problem or am I just special??
Thanks
Gareth
Private Function extractWordFile Text(ByVal filename As String) As
String
Dim fileContent As String
Dim wordApp As New Word.Applicatio nClass
Dim nullObject As Object = System.Reflecti on.Missing.Valu e
Dim wordDoc As Word.Document = wordApp.Documen ts.Open(filenam e, _
nullObject, _
nullObject, _
nullObject, _
nullObject, _
nullObject, _
nullObject, _
nullObject, _
nullObject, _
nullObject, _
nullObject, _
nullObject, _
nullObject, _
nullObject, _
nullObject)
wordDoc.ActiveW indow.Selection .WholeStory()
wordDoc.ActiveW indow.Selection .Copy()
Dim data As System.Windows. Forms.IDataObje ct =
System.Windows. Forms.Clipboard .GetDataObject( )
fileContent =
data.GetData(Sy stem.Windows.Fo rms.DataFormats .Text).ToString ()
wordDoc.Close()
End Function