Word ActiveWindow Selection Copy failing

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • garethrichardadams@gmail.com

    #1

    Word ActiveWindow Selection Copy failing

    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

Working...