Create Recordset from a word table

noccy

Registered User.
Local time
Today, 14:19
Joined
Aug 19, 2003
Messages
67
Anyone got a suggestion on how I can create a Recordset from a Word table?

I'm working from Access

tnx

noccy
 
u mean table create by the ms word?
 
yes a table in a ms word document
 
I'm not quite sure what u wanna do but as u say u wanna do a recordset to likn to word so mayb this may help

code:
___________________________________________________
Option Explicit
Const sFileName = "C:\temp\db1.mdb"

Private Sub Command1_Click()
' Declare our variables
Dim oWord As Word.Application
Dim oDoc As Word.Document
Dim oRange As Word.Range
Dim oConn As ADODB.Connection
Dim oRS As ADODB.Recordset
Dim sTemp As String

' Create an instance of Word
Set oWord = CreateObject("Word.Application")
' Show Word to the user
oWord.Visible = True

' Add a new, blank document
Set oDoc = oWord.Documents.Add
' Get the current document's range object
Set oRange = oDoc.Range

' Create a new ADO connection
Set oConn = CreateObject("ADODB.Connection")
' Open our connect
oConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & _
sFileName & ";Persist Security Info=False"
' Execute a SQL statement to retrieve the information
Set oRS = oConn.Execute( _
"SELECT CustomerID, CompanyName, ContactName FROM Customers")
' Use GetString to return the recordset as a string
sTemp = oRS.GetString(adClipString, -1, vbTab)

' Insert a heading on the string
sTemp = "Customer ID" & vbTab & "Company Name" & _
vbTab & "Contact Name" & vbCrLf & sTemp
' Insert the data into the Word document
oRange.Text = sTemp
' Convert the text to a table and format the table
oRange.ConvertToTable vbTab, , , , wdTableFormatColorful2
End Sub
____________________________________________________
 
Well what I want to do is to create a recordset from an existing table in an existing word document.

I have a standard word document from a template I made mysef. This document has one table in it, and i want to access the data in this table by creating a recordset.....

noccy
 
noccy,


What you mean is you've created a table in the word document and you want access to look for data in this table?
 

Users who are viewing this thread

Back
Top Bottom