【问题标题】:Sending multiple Excel exports to zipped folder on user's desktop将多个 Excel 导出发送到用户桌面上的压缩文件夹
【发布时间】:2022-11-18 22:36:06
【问题描述】:

我一点也不熟悉 Access 或 VBA,但不幸的是,它需要用于我与另一个程序一起使用的导出/导入集。下面是我需要导出到 Excel 的三个表格,但我想知道是否可以将所有三个表格以 zip 格式保存到当前用户的桌面。

Function Macro11()
On Error GoTo Macro11_Err

    DoCmd.OutputTo acOutputTable, "UB_Donors", "ExcelWorkbook(*.xlsx)", "", False, "", , acExportQualityPrint
    DoCmd.OutputTo acOutputTable, "UB_DonationHistory", "ExcelWorkbook(*.xlsx)", "", False, "", , acExportQualityPrint
    DoCmd.OutputTo acOutputTable, "UB_DonationValues", "ExcelWorkbook(*.xlsx)", "", False, "", , acExportQualityPrint


Macro11_Exit:
    Exit Function

Macro11_Err:
    MsgBox Error$
    Resume Macro11_Exit

End Function

我真的很感激你的帮助,或者任何我能得到正确方向的机会。

谢谢!

【问题讨论】:

    标签: excel vba ms-access


    【解决方案1】:

    有可能的。

    您可以使用我的 Zip 函数,位于GitHub在我的项目VBA.Compress 模块FileCompress.bas 中:

    ' Zip a file or a folder to a zip file/folder using Windows Explorer.
    ' Default behaviour is similar to right-clicking a file/folder and selecting:
    '   Send to zip file.
    '
    ' Parameters:
    '   Path:
    '       Valid (UNC) path to the file or folder to zip.
    '   Destination:
    '       (Optional) Valid (UNC) path to file with zip extension or other extension.
    '   Overwrite:
    '       (Optional) Leave (default) or overwrite an existing zip file.
    '       If False, the created zip file will be versioned: Example.zip, Example (2).zip, etc.
    '       If True, an existing zip file will first be deleted, then recreated.
    '
    '   Path and Destination can be relative paths. If so, the current path is used.
    '
    '   If success, 0 is returned, and Destination holds the full path of the created zip file.
    '   If error, error code is returned, and Destination will be zero length string.
    '
    ' Early binding requires references to:
    '
    '   Shell:
    '       Microsoft Shell Controls And Automation
    '
    '   Scripting.FileSystemObject:
    '       Microsoft Scripting Runtime
    '
    ' 2022-04-20. Gustav Brock. Cactus Data ApS, CPH.
    '
    Public Function Zip( _
        ByVal Path As String, _
        Optional ByRef Destination As String, _
        Optional ByVal Overwrite As Boolean) _
        As Long
    

    < snip - 代码太多,无法在此处发布>

    完整文档:

    Zip and unzip files and folders with VBA the Windows Explorer way

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-02-09
      • 1970-01-01
      • 2016-09-04
      • 1970-01-01
      • 1970-01-01
      • 2023-03-19
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多