VBA/Excel/Access/Word/Access/Access Import Export

Материал из VB Эксперт

Перейти к: навигация, поиск

Содержание

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