Access 2007/2010选择性导出为Excel 2007或CSV文件

2014-10-27 0 812
Access 2007/2010选择性导出为Excel 2007或CSV文件
Sub ExportExcelCSV()
  Dim strOut As String
  Dim tbl As AccessObject
  Dim f As Boolean

  With Application.FileDialog(4) ' msoFileDialogFolderPicker
    .Title = "Please select the target folder"
    If .Show Then
      strOut = .SelectedItems(1)
      If Not Right(strOut, 1) = "\" Then
        strOut = strOut & "\"
      End If
    Else
      MsgBox "You didn't select a target folder.", vbExclamation
      Exit Sub
    End If
  End With
  f = (MsgBox("Do you want to export all tables to Excel (No = CSV)?", _
    vbQuestion + vbYesNo) = vbYes)

  For Each tbl In CurrentData.AllTables
    If Not tbl.Name Like "MSys*" And Not tbl.Name Like "~" Then
      If f Then
        DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel12Xml, _
          tbl.Name, strOut & tbl.Name & ".xlsx", True
      Else
        DoCmd.TransferText acExportDelim, , _
          tbl.Name, strOut & tbl.Name & ".csv", True
      End If
    End If
  Next tbl
End Sub

遇见资源网 ASP/Basic Access 2007/2010选择性导出为Excel 2007或CSV文件 http://www.ox520.com/13355.html

下一篇: 链接列表
常见问题

相关文章

发表评论
暂无评论
官方客服团队

为您解决烦忧 - 24小时在线 专业服务