ich habe ein Makro per Rekorder aufgenommen.
Wie kann ich den pfad so bestimmen der pfad aus einer Zelle genommen wird.
z.B.:
pfad = [A1]
Und in A1 steht dann der pfad woher die CSV genommen werden soll.
Danke Gruß
Sub Import()
' import CSV von fester Adresse
Application.WindowState = xlMaximized
ActiveWorkbook.Queries.Add Name:="DataBase", Formula:= _
"let" & Chr(13) & "" & Chr(10) & " Quelle = Csv.Document(File.Contents(""C:\Users\ _
User\Desktop\DataBase1.csv""),[Delimiter="","", Columns=41, Encoding=1252, QuoteStyle=QuoteStyle.None])," & Chr(13) & "" & Chr(10) & " #""Erste Zeile als Überschriften verwenden"" = Table.PromoteHeaders(Quelle, [PromoteAllScalars=true])," & Chr(13) & "" & Chr(10) & " #""Typ ändern"" = Table.TransformColumnTypes(#""Erste Zeile als Überschriften verwenden" & _
""",{{""Product NB"", type text}, {""End Product NB"", type text}, {""Product Enabled"", _
type logical}, {""Product Type"", type text}, {""OEM (client)"", type text}, {""Test sequence"", type text}, {""BS version"", type text}, {""Programming version"", type text}, {""OnChip"", type text}, {""iO Flag in EEProm Address or none"", type text}, {""Supplier"", t" & _
"ype text}, {""Machine Type"", type text}, {""Machines allowed"", Int64.Type}, {"" _
Retest Count Limit"", Int64.Type}, {""Adapter Name"", type text}, {""Top Adapter Channel 1"", type text}, {""Top Adapter Channel 2"", type text}, {""Product Adapter Top 1 "", type text}, {""Bottom Adapter Channel 1"", Int64.Type}, {""Bottom Adapter Channel 2"", Int64.Type}, {""Product A" & _
"dapter bottom 1"", type text}, {""LED Adapter "", type logical}, {""Scanner in Adapter" _
", type logical}, {""Auto Lid detection flag"", type logical}, {""Auto Panel detection flag"", type logical}, {""Auto Board detection flag"", type logical}, {""Bad box flag"", type logical}, {""Release button flag"", type logical}, {""panel"", type text}, {""Multi in one adapt" & _
"er"", type text}, {""MES booking for bad part"", type text}, {""Print out / Label for _
Pass part"", type logical}, {""Print out for bad part"", type logical}, {""Good board marker"", type logical}, {""Golden Sample SNR"", type number}, {""Short-circuit plate"", type logical}, {""Creator"", type text}, {""Date of creation"", type number}, {""Name "", type text}, {""" & _
"Date of change"", type number}, {""Comments"", type text}})" & Chr(13) & "" & Chr(10) & _
"in" & Chr(13) & "" & Chr(10) & " #""Typ ändern"""
ActiveWorkbook.Worksheets.Add
With ActiveSheet.ListObjects.Add(SourceType:=0, Source:= _
"OLEDB;Provider=Microsoft.Mashup.OleDb.1;Data Source=$Workbook$;Location=DataBase; _
Extended Properties=""""" _
, Destination:=Range("$A$1")).QueryTable
.CommandType = xlCmdSql
.CommandText = Array("SELECT * FROM [DataBase]")
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.PreserveColumnInfo = True
.ListObject.DisplayName = "DataBase"
.Refresh BackgroundQuery:=False
End With
Range("DataBase[#Headers]").Select
End Sub