VB.Net and Word

K

Ken

I'm trying to extract data from a Word table. I can get
the documents to open in my prototype. I'm told that to
get to the information in the cell, I need the following:

activedocument.Tables(1).Cell(1,1).Range.Text

However, when I try to go beyond activedocument.Tables, I
get: Interface 'Word.Tables' cannot be indexed because it
has no default property.

Is there something else I need here, or is there an
easier way to do this?

Thanks!

Imports System.IO
Imports Word
Public Class Form1
Inherits System.Windows.Forms.Form

Public Const DataPath As String = "c:\sleep\"
Public Const ArchivePath As String
= "c:\sleep\archive\"

Private Sub Button1_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
Button1.Click
Dim DataDir As DirectoryInfo = New DirectoryInfo
(DataPath)
Dim Files As FileInfo() = DataDir.GetFiles
("*.rtf")
Dim sFile As FileInfo
Dim strName As String
Dim wrd As Word.Application = New Word.Application
wrd.Visible = True
Dim doc As Word.Document
Dim tableval As String

For Each sFile In Files
strName = DataPath & sFile.ToString
MsgBox(strName)
doc = wrd.Documents.Open(strName)
tableval = wrd.ActiveDocument.Tables(1)

Next
wrd.Quit()
End Sub
End Class
 
A

Armin Zingler

Ken said:
I'm trying to extract data from a Word table. I can get
the documents to open in my prototype. I'm told that to
get to the information in the cell, I need the following:

activedocument.Tables(1).Cell(1,1).Range.Text

However, when I try to go beyond activedocument.Tables, I
get: Interface 'Word.Tables' cannot be indexed because it
has no default property.

Is there something else I need here, or is there an
easier way to do this?

Tables.Item(1).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top