"Excel is a great tool for formatting data that you've extracted from tables or views. You can copy such data into an Excel spreadsheet straight from SQL Management Studio's output grid. Unfortunately there's no way to also grab the column names, so unless you have some way of generating them, you're stuck either omitting them or filling them in by hand."
David I like your articel but one question:
As you incoporate VBA macros why not use ADO as alternative to get out the data from
SQL Server. This is easier and you can get the column the names by a method like:
Just part of the script
I use this one to print TAB sep files with column headers
Dim rs As New ADODB.Recordset
Dim utskriftrad as string
Dim K as long
cmd.CommandText = sqltext 'An SQL statement
For K = 0 To rs.Fields.Count - 1
utskriftrad = utskriftrad & rs.Fields(K).Name & Chr(9)
print utskriftrad etc
I yesterday wrote an article to SQL ServerCentral maybe that one will be
accepted. And there is a lot more to write how to interact with Excel.