Im untenstehenden Code wird eine Csv Datei aus dem Verzeichniss C:\Users\erich\OneDrive\!alle filme1.csv ausgewählt und dann in die Tabelle FilmDB kopiert und eingefügt.
Frage:
Was sollte ich in dem Code ändern damit die lästigen Abfrage nicht kommt (Datei auswählen)
Es soll einfach die Datei !alle filme1.csv geladen werden und
alles kopiert und eingefügt werden ohne der lästigen Abfrage welche Datei die steht ja sowieso fest.
'Importiert aus Csv Datei neue Daten Atualisiertt FilmDB
Private Sub CommandButton8_Click()
Application.EnableEvents = False
Const FILE_PATH As String = "E:\"
Dim strFilename As String
Dim lngRow As Long
Dim strFilePath As String
Dim objFileDialog As FileDialog
Dim objWorkbook As Workbook
Application.ScreenUpdating = False
'Löscht alle Bilder aus Kommentaren
Worksheets("FilmDB").Activate
Columns("B:B").Select
Selection.ClearComments
Set objFileDialog = Application.FileDialog(fileDialogType:=msoFileDialogOpen)
With objFileDialog
.AllowMultiSelect = False
.FilterIndex = 6
.InitialFileName = "C:\Users\erich\OneDrive\!alle filme1.csv" ' Anpassen !!!
.Title = "Importdatei auswählen"
If .Show Then strFilePath = .SelectedItems(1)
End With
Set objFileDialog = Nothing
If strFilePath vbNullString Then
Set objWorkbook = Workbooks.Open(Filename:=strFilePath)
Call objWorkbook.Worksheets(1).Columns("A:J").Copy(Destination:=ThisWorkbook. _
ActiveSheet.Cells(1, 1))
Call objWorkbook.Close(SaveChanges:=False)
Set objWorkbook = Nothing
End If
Application.ScreenUpdating = True
End Sub
GrußOraculix