Infinite
More left to learn.
- Local time
- Yesterday, 23:28
- Joined
- Mar 16, 2015
- Messages
- 402
Hello! How would I go about importing .xlsx files? I want a code that would do this. Something the user can just click, and it would import him the .xlsx file. The way im getting the .xlsx file is from this code:
That is the code the get the file. Now all I have to figure out is how to import them.
1: The format would be the same for all of the imports
2: There should only be a max of 3 files with different headers and such.
3: I need that imported into a table. I plan on using a update query to update my sales table. That way the user can import the sales with a click of a button.
4: I want access to delete the file when it imports it. That way there are not 3 .xlsx files. !DONE!
Those are the 4 highlights. I should be able to figure out how to delete a file myself, and the format should be fine. I just dont know how to import.
Thanks for all your help!
EDIT: I want it hard imported into my database. Not just attached, or linked.
Code:
Private Sub Command10_Click()
Dim csvFile As String
Dim txtFile As String
Dim xlsxFile As String
csvFile = Dir("C:\Users\Joshua\Downloads\!Import Sales From Online\*.csv")
txtFile = Dir("C:\Users\Joshua\Downloads\!Import Sales From Online\*.txt")
xlsxFile = Dir("C:\Users\Joshua\Downloads\!Import Sales From Online\*.xlsx")
If Len(Dir("C:\Users\Joshua\Downloads\!Import Sales From Online\*.csv")) = 0 Then
MsgBox "There are NO .csv file(s)."
Else
MsgBox "There is a .csv file."
End If
If Len(Dir("C:\Users\Joshua\Downloads\!Import Sales From Online\*.txt")) = 0 Then
MsgBox "There are NO .txt file(s)."
Else
MsgBox "There is a .txt file."
End If
If Len(Dir("C:\Users\Joshua\Downloads\!Import Sales From Online\*.xlsx")) = 0 Then
MsgBox "There are NO .xlsx file(s)."
Else
MsgBox "There is a .xlsx file."
End If
End Sub
That is the code the get the file. Now all I have to figure out is how to import them.
1: The format would be the same for all of the imports
2: There should only be a max of 3 files with different headers and such.
3: I need that imported into a table. I plan on using a update query to update my sales table. That way the user can import the sales with a click of a button.
4: I want access to delete the file when it imports it. That way there are not 3 .xlsx files. !DONE!
Those are the 4 highlights. I should be able to figure out how to delete a file myself, and the format should be fine. I just dont know how to import.
Thanks for all your help!
EDIT: I want it hard imported into my database. Not just attached, or linked.
Last edited: