Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default How to create a Linked (text) table in xl vba to a .mdb

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;Characte rSet=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
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
VBA to create Pivot table from text file Bill Excel Programming 2 September 3rd 06 01:53 AM
Insert rows in linked table that are added to secondary table Ida LaValley Excel Discussion (Misc queries) 2 August 21st 06 10:52 PM
How to create a Pivot table from text file with more than 65000 rows? morchard Excel Discussion (Misc queries) 0 June 29th 05 08:50 PM
create space in line chart between points, linked to pivot table Mike -Z- Charts and Charting in Excel 1 December 7th 04 09:39 PM
create pivot table linked to another pivot? possible? scottwilsonx[_23_] Excel Programming 1 August 12th 04 08:54 AM


All times are GMT +1. The time now is 10:24 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"