精品伊人久久大香线蕉,开心久久婷婷综合中文字幕,杏田冲梨,人妻无码aⅴ不卡中文字幕

打開APP
userphoto
未登錄

開通VIP,暢享免費電子書等14項超值服

開通VIP
Excel VBA把Excel導(dǎo)入到Access中(TransferSpreadsheet)

導(dǎo)入單個EXCEL文件

Sub Export_Sheet_Data_ToAccess()
Dim myFile As Variant
Dim AppAccess As New Access.Application
Dim wbPath As String


myFile = Application.GetOpenFilename("Excel Files (*.xls), *.xls")
If VarType(myFile) = vbBoolean Then
       MsgBox "CanCel by User!"
       Exit Sub
End If

Application.ScreenUpdating = False
wbPath = ThisWorkbook.Path & "\"

With AppAccess
       .OpenCurrentDatabase wbPath & "CheckIn.mdb", True
       .DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel9, "data", myFile, True
       .CloseCurrentDatabase
End With

Application.ScreenUpdating = True
MsgBox myFile & Chr(10) & " Export is Done!"

Set AppAccess = Nothing
End Sub

導(dǎo)入多個EXCEL文件

Sub Export_MultiSheets_Data_ToAccess()
Dim myFiles As Variant, vItem As Variant
Dim AppAccess As New Access.Application
Dim wbPath As String

myFiles = Application.GetOpenFilename( _
       "Excel Files (*.xls), *.xls", , "Select All Files", , True)
If VarType(myFiles) = vbBoolean Then
       MsgBox "CanCel by User!"
       Exit Sub
End If

Application.ScreenUpdating = False
wbPath = ThisWorkbook.Path & "\"

With AppAccess
       .OpenCurrentDatabase wbPath & "CheckIn.mdb", True
       If IsArray(myFiles) Then
         For Each vItem In myFiles
            .DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel9, "data", vItem, True
         Next
       End If
       .CloseCurrentDatabase
End With

Application.ScreenUpdating = True
MsgBox " Export is Done!"

Set AppAccess = Nothing
End Sub

導(dǎo)入一個工作簿下的所有工作表

Sub Export_Sheets_Data_ToAccess()
Dim myFile As Variant
Dim AppAccess As Access.Application
Dim wbPath As String
Dim objWb As Workbook
Dim rngData As Range
Dim lRow As Long
Dim lCol As Long
Dim arr() As Variant
Dim iSht As Integer

Set AppAccess = New Access.Application

myFile = Application.GetOpenFilename("Excel Files (*.xls), *.xls")
If VarType(myFile) = vbBoolean Then
       MsgBox "CanCel by User!"
       Exit Sub
End If

Application.ScreenUpdating = False
Set objWb = GetObject(myFile)
ReDim arr(1 To objWb.Sheets.Count)
For iSht = 1 To objWb.Sheets.Count
       With objWb.Sheets(iSht)
         lRow = .[a65536].End(xlUp).Row
         lCol = .[iv1].End(xlToLeft).Column
         Set rngData = .Range(.Cells(1, 1), .Cells(lRow, lCol))
         arr(iSht) = .Name & "!" & rngData.Address(0, 0)
       End With
Next
objWb.Close False
Set objWb = Nothing


wbPath = ThisWorkbook.Path & "\"

With AppAccess
       .OpenCurrentDatabase wbPath & "Database.mdb", True
       For iSht = 1 To UBound(arr)
         .DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel9, _
            "data", myFile, True, arr(iSht)
       Next
       .CloseCurrentDatabase
End With

Application.ScreenUpdating = True
MsgBox myFile & Chr(10) & " Export is Done!"

Set AppAccess = Nothing
End Sub

本站僅提供存儲服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點擊舉報
打開APP,閱讀全文并永久保存 查看更多類似文章
猜你喜歡
類似文章
Excel VBA編程的常用代碼
用VBA提取路徑下所有工作簿的工作表名(四個方法)
VBA讀取word中的內(nèi)容到Excel中
EXCEL跨表取值匯總
VBA遍歷當前目錄下指定類型的excel文件并復(fù)制文件內(nèi)指定的內(nèi)容到新表中
如何使用VBA實現(xiàn)將多個Excel文件中的數(shù)據(jù)復(fù)制到某個Excel文件中
更多類似文章 >>
生活服務(wù)
分享 收藏 導(dǎo)長圖 關(guān)注 下載文章
綁定賬號成功
后續(xù)可登錄賬號暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點擊這里聯(lián)系客服!

聯(lián)系客服

主站蜘蛛池模板: 奉新县| 绵阳市| 玛多县| 鄯善县| 哈尔滨市| 杂多县| 兴城市| 鄂托克旗| 正宁县| 蓬溪县| 古交市| 南平市| 改则县| 凉城县| 宁远县| 丁青县| 高平市| 奉新县| 磐安县| 福泉市| 车险| 石台县| 襄樊市| 余庆县| 陇西县| 渭源县| 惠水县| 天全县| 名山县| 衡阳县| 梅州市| 巴中市| 邵阳市| 崇明县| 霍邱县| 邯郸县| 介休市| 成武县| 通渭县| 基隆市| 花莲市|