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