Dim
cn
As
Object
Dim
rs
As
Object
Dim
sql
As
String
Dim
start_row
As
Integer
: start_row = 1
Dim
start_col
As
Integer
: start_col = 1
Dim
iCol
As
Integer
Set
cn = CreateObject(“ADODB.Connection”)
With
cn
.Provider =
"Microsoft.ACE.OLEDB.12.0"
.ConnectionString =
"Data Source="
& ThisWorkbook.Path & "\" & _
ThisWorkbook.Name &
";"
& _
"Extended Properties="
"Excel 12.0 Xml;HDR=YES"
";"
.Open
End
With
sql =
"Select * from [Aktuelle_Aufträge$]"
Set
rs = cn.Execute(sql)
Worksheets(
"verfügbare_Aufträge"
).Cells(start_row, start_col).CurrentRegion.Clear
For
iCols = 0
To
rs.Fields.Count - 1
Worksheets(
"verfügbare_Aufträge"
).Cells(start_row, start_col + iCols).Value = _
rs.Fields(iCols).Name
Next
Worksheets(
"verfügbare_Aufträge"
).Cells(start_row + 1, start_col).CopyFromRecordset rs
rs.Close
Set
rs =
Nothing
cn.Close
Set
cn =
Nothing
End
Sub