Importing of Excel 97 files when you want the user to be prompted for file name and location to allow for changing directories and file names - but always to the same Access table (this is with the first example from the FAQ - Importing Excel 97 Files Into Access Using VB Code).
The following names would need to be added or changed depending upon your database, but the punctuation would remain:
AccessTableName = The name of the table in your database to which you wish to add the records. TitleOfMessageBox = The title you wish to have on your message box. YouCanAddDefaultLocationHere = If you want to give the user a default location from which to import.
Importing of Excel 97 files when you want the user to be prompted for file name and location to allow for changing directories and file names, but always to the same Access table. This is to import the entire first worksheet if it does not have Field Names included, to include field names change the last "0" to "-1"
You would use a series of statements as such: Dim Message, Default, PathValue, Message2, FileValue As String
Dim Title
Message = "Enter the path name."
Message2 = "Enter the file name."
Title = "TitleOfMessageBox"
Default = "YouCanAddADefaultLocationHere"
FileValue = InputBox(Message2, Title, Default)
PathValue = InputBox(Message, Title, Default) & FileValue
DoCmd.TransferSpreadsheet acImport, 8, "AccessTableName", PathValue, 0
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.