PC Review


Reply
Thread Tools Rate Thread

How to create a Linked (text) table in xl vba to a .mdb

 
 
Magnus Å
Guest
Posts: n/a
 
      13th Nov 2008
Hello!

I´m trying to make a linked table to a text file using Excel VBA using ADO?
But I can´t make it to work. i only got "Cant find the path"

Please help me!

Here is my code:

Function CreateExternalTable()
Dim conn As ADODB.Connection
Dim tbl As ADOX.Table
Dim cat As ADOX.Catalog

On Error Resume Next
Kill "C:\Documents and Settings\Magnus\My Documents\Teknik i
Tiden\Proj 7" & "\GOTSTG.mdb"
On Error GoTo 0


Set conn = New ADODB.Connection
With conn
.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=C:\Documents and Settings\Magnus\My
Documents\Teknik i Tiden\Proj 7\GOTSTG.mdb;"
'.Open
End With

Set cat = New ADOX.Catalog
cat.Create conn

Set tbl = New ADOX.Table

With tbl
.Name = "GOTST_link"
Set .ParentCatalog = cat
.Properties("Jet OLEDB:Link Datasource") = "Data Source=C:\Documents and
Settings\Magnus\My Documents\Teknik i Tiden\Proj 7\GOTSTG_link.txt"
.Properties("Jet OLEDB:Link Provider String") = "Text;DSN=GOTSTG Link
Specification;FMT=Delimited;HDR=NO;IMEX=2;CharacterSet=1252;DATABASE=C:\Documents and Settings\Magnus\My Documents\Teknik i Tiden\Proj 7;TABLE=GOTSTG#txt"
'.Properties("Jet OLEDB:Remote Table Name") = "GOTSTG_link"
.Properties("Jet OLEDB:Create Link") = True
End With
cat.Tables.Append tbl
conn.Close

End Function

Thanks in advance

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Create Linked Table to AS/400 Matthew Pfluger Microsoft Access Database Table Design 6 20th Nov 2008 08:17 PM
Create table using data from linked table Tommy Microsoft Access 1 17th Aug 2007 10:26 AM
create a linked table =?Utf-8?B?R2VyaGFyZCBIdWVzc25lcg==?= Microsoft Access External Data 11 2nd May 2006 02:03 PM
When I create a new item in my table, how can I create on in a linked table also? PaulHilgeman Microsoft Access Forms 4 17th Feb 2006 01:25 AM
Create Linked Table Wayne Wengert Microsoft VB .NET 4 7th Mar 2005 08:40 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:25 AM.