VBA/Excel/Access/Word/Access/Access Import Export — различия между версиями
Admin (обсуждение | вклад) м (1 версия) |
|
(нет различий)
|
Версия 16:33, 26 мая 2010
Содержание
- 1 Export table as html page
- 2 Export table as htx file
- 3 Export table as rtf file
- 4 Export table as txt file
- 5 Export table as xls file
- 6 Export table to asp page
- 7 Export to a Comma Separated File
- 8 Export to a Fixed Width File
- 9 Importing from a Comma Separated File
- 10 Importing from a Fixed Width File
- 11 Transfer database through ODBC
Export table as html page
Public Sub ExportTable()
DoCmd.OutputTo acOutputTable, "tblCustomer", acFormatHTML, _
"C:\BegVBA\Customer.html"
End Sub
Export table as htx file
Public Sub ExportTable()
DoCmd.OutputTo acOutputTable, "tblCustomer", acFormatIIS, _
"C:\BegVBA\Customer.htx"
End Sub
Export table as rtf file
Public Sub ExportTable()
DoCmd.OutputTo acOutputTable, "tblCustomer", acFormatRTF, _
"C:\BegVBA\Customer.rtf"
End Sub
Export table as txt file
Public Sub ExportTable()
DoCmd.OutputTo acOutputTable, "tblCustomer", acFormatTXT, _
"C:\BegVBA\Customer.txt"
End Sub
Export table as xls file
Public Sub ExportTable()
DoCmd.OutputTo acOutputTable, "tblCustomer", acFormatXLS, _
"C:\BegVBA\Customer.xls"
End Sub
Export table to asp page
Public Sub ExportTable()
DoCmd.OutputTo acOutputTable, "Employees", acFormatASP, _
"C:\Customer.asp"
End Sub
Export to a Comma Separated File
Sub export()
DoCmd.TransferText acExportDelim, "CompanyDelimited", "tblCompany", _
"C:\Delimited.txt", True
MsgBox "Company details exported"
End Sub
Export to a Fixed Width File
Sub text()
DoCmd.TransferText acExportFixed, "CompanyFixed", "tblCompany", _
"C:\Fixed.txt", True
MsgBox "Company details exported"
End Sub
Importing from a Comma Separated File
Sub main()
DoCmd.TransferText acImportDelim, "CompanyDelimited", "tblCompanyDelimited", _
"C:\Delimited.txt", True
MsgBox "Company details imported"
End Sub
Importing from a Fixed Width File
Sub import()
DoCmd.TransferText acImportFixed, "CompanyFixed", "tblCompanyFixed", _
"C:\Fixed.txt", True
MsgBox "Company details imported"
End Sub
Transfer database through ODBC
Sub TestLinkTransferDatabase()
DoCmd.TransferDatabase acLink, "ODBC Database", _
"ODBC;DSN=DataSourceName;UID=username;PWD=pwd;LANGUAGE=us_english;" _
& "DATABASE=yourDatabase", acTable, "Sales", "dboSales"
End Sub