Posted By


lolrenx on 03/13/13

Tagged


Statistics


Viewed 810 times
Favorited by 0 user(s)

Sheets_List_From_File


/ Published in: Visual Basic
Save to your folder(s)

lists sheets without opening the file


Copy this code and paste it in your HTML
  1. Private Function Sheets_List_From_File(SourceFileFullName As String, SheetNames As Variant, Separator As String) As String
  2.  
  3. Dim cn As Object, cat As Object, tbl As Object, str$
  4. Set cn = CreateObject("ADODB.Connection")
  5. Set cat = CreateObject("ADOX.Catalog")
  6. Set tbl = CreateObject("ADOX.Table")
  7. cn.Open "dsn=excel files;dbq=" & SourceFileFullName
  8. cat.ActiveConnection = cn
  9. For Each tbl In cat.Tables
  10. str = str & Replace(tbl.Name, "$", "") & Separator
  11. Next
  12. 'MsgBox str
  13. cn.Close
  14. Set cn = Nothing
  15. Set cat = Nothing
  16. Set tbl = Nothing
  17.  
  18. Sheets_List_From_File = str
  19.  
  20. End Function

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.