VBA/Excel/Access/Word/Access/Access Import Export — различия между версиями

Материал из VB Эксперт
Перейти к: навигация, поиск
м (1 версия)
 
м (1 версия)
 
(нет различий)

Текущая версия на 12:46, 26 мая 2010

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