LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default get column name by ADOX

Good day Group,

Uses the code below to get the worksheet names from a closed workbook,
How to modify the code to also get the column name of the first column
into the listbox? Grateful for help,

Brgds

CG Rosen


Sub GetSheetNames()

Dim cnn As ADODB.Connection
Dim cat As ADOX.Catalog
Dim tbl As ADOX.Table
Dim lRow As Long
Dim szConnect As String
Dim szTableName As String
Dim Columns As ADOX.Columns

szBookName = sConString1

If Val(Application.Version) < 12 Then

szConnect = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & sConString & ";" & _
"Extended Properties=Excel 8.0;"
Else

szConnect = "Provider=Microsoft.ACE.OLEDB.12.0;" & _
"Data Source=" & sConString1 & ";" & _
"Extended Properties=Excel 12.0 Xml;"
End If

Set cnn = New ADODB.Connection
cnn.Open szConnect
Set cat = New ADOX.Catalog
Set cat.ActiveConnection = cnn

UserForm1.ListBox1.Clear

For Each tbl In cat.Tables

szTableName = tbl.Name
If Right(szTableName, 1) = "$" Then
item1 = Left(szTableName, Len(szTableName) - 1)
UserForm1.ListBox1.AddItem item1
?????????????????????????????????????????????

End If

Next tbl

cnn.Close
Set cat = Nothing
Set cnn = Nothing

End Sub

 
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
Ado / Adox ? silvest[_21_] Excel Programming 0 November 6th 04 10:41 PM
Ado / Adox ? silvest[_20_] Excel Programming 1 November 6th 04 09:55 PM
Ado / Adox ? silvest[_17_] Excel Programming 2 November 6th 04 09:35 PM
Ado / Adox ? silvest[_19_] Excel Programming 0 November 6th 04 05:53 PM
Ado / Adox ? silvest[_18_] Excel Programming 1 November 5th 04 11:22 PM


All times are GMT +1. The time now is 11:45 PM.

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"