vba - How to specify a different file path for a saved Excel import -
I use the doCmd.TransferText
to use a saved text import specification several times However, I think that I select a file to select that file from a application.FileDialog (msoFileDialogFilePicker)
file Can easily save the path.
One way to do this with Excel file is to save the Excel import specification, but there is no way to use saved import using the DoCmd.TransferSpreadSheet
method. There is no option to specify a file path in addition, as well as DoCmd.RunSavedImportExport
.
Is there any work for this except for using any other file type (for example .csv)
ImportExportSpecification
items stored in the "saved item import" and "saved export" and "saved export" access excel import Details of something like the following XML will appear, which I manually import excel spreadsheets and the end of the import wizard "Save import steps to re page created by" checkbox Czech. & lt ;? Xml version = "1.0" encoding = "UTF-8"? & Gt; & Lt; ImportExportSpecification Path = "C: \ User \ Guord \ Desktop \ xlsxTest.xlsx" xmlns = "XB: www.microsoft.com/office/access/imexspec" & gt; & Lt; ImportExcel first name = "true" destination = "xlsxTest" category = "sheet 1 $" & gt; & Lt; Column PrimaryKey = "ID" & gt; & Lt; Column name = "call1" field name = "id" indexed = "userplex" SkipColumn = "false" datatype = "long" /> & Lt; Column name = "call 2" field name = "textfield" indexed = "no" SkipColumn = "false" datatype = "text" /> & Lt; Column name = "call3" field name = "datefield" indexed = "no" SkipColumn = "false" datatype = "datetime" /> & Lt; / Column & gt; & Lt; / ImportExcel & gt; & Lt; / ImportExportSpecification & gt;
ImportExportSpecification name was saved with import-xlsxTest
. Now, if I change the name of the excel file from "xlsxTest.xlsx" to "another.Test.xlsx", then I import the Export SPP for the name of the file to change the name and then import the following VBA code Use:
option database option clear compare sub-duxcel import (import) as ipod explanation, as long as i , Old xma () String as, string cost newXlsxFileSpec = "test for test" as "C: \ Users \ Gord \ Desktop" \ "Other \ test.clux" "current project.Exportport Exports (" Import-XLSXTist ") = Split (ISXML, VBCRLF, -1, VBBry ComparEre) NewXML = "" I = 0 for Ubound (Old XML) if I = 1 then 'Existing XML NewLL = NewXML & amp; _ "& Lt; Import Export Explanation Path = "" & amp; _ NewXlsxFileSpec & amp; _ "" "Xmlns =" "vase: www.microsoft.com/office/access/imexspec" "& gt;" & Amp; _ VbCrLf Else newXML = newXML & Old XML (I) & VbCrLf End if Next Inx XML = New XML AE Execute Set ies = None End Sub
ImportExportSpecification
For more information about items, see
Comments
Post a Comment