VBA调用CSV文件

时间:2017-05-30 20:05:51

标签: excel vba scripting

这是我的情景。我有一个在服务器上运行的脚本,它将已用空间,可用空间等导出到csv文件。 我有一个主excel.xlsm,它从那些csv文件中调用数据。但它们是外部链接,因此它会继续弹出,要求更新这些链接,但文件已关闭。我已尝试过displayalerts = false等几个版本。但没有任何效果。这是我运行所有内容的宏:

Private Sub Auto_Open()

    'MsgBox "This Excel Document will open and then close source files to update data."
    'Opens the Source CSV files so the Main Spreadsheet can update its external values.
    Application.DisplayAlerts = False
    Workbooks.Open "\\Engineering\CADD Admin\EngineeringDriveSpace\CSV_Docs\DiskReportFDrive.csv"
    Workbooks.Open "\\Engineering\CADD Admin\EngineeringDriveSpace\CSV_Docs\DiskReportGDrive.csv"
    Workbooks.Open "\\Engineering\CADD Admin\EngineeringDriveSpace\CSV_Docs\DiskReportHDrive.csv"
    Workbooks.Open "\\Engineering\CADD Admin\EngineeringDriveSpace\CSV_Docs\DiskReportJDrive.csv"
    Workbooks.Open "\\Engineering\CADD Admin\EngineeringDriveSpace\CSV_Docs\DiskReportKDrive.csv"

    'Makes the Main Spreadsheet Active
    'Activate Worksheet
    'Workbooks("EngineeringDriveSpace.xlsm").Activate
    Workbooks.Open "c:\users\nicholas.henry\Downloads\EngineeringDriveSpace.xlsm", UpdateLinks:=xlUpdateLinksAlways
    'Worksheets("MH07_F").Activate
    'Sheets("MH07_F").Select

    'Pause Application For Testing
    'Application.Wait Now + #12:00:01 AM#

    'Closes the Source CSV files.

    Workbooks("DiskReportFDrive.csv").Close SaveChanges:=False
    Workbooks("DiskReportGDrive.csv").Close SaveChanges:=False
    Workbooks("DiskReportHDrive.csv").Close SaveChanges:=False
    Workbooks("DiskReportJDrive.csv").Close SaveChanges:=False
    Workbooks("DiskReportKDrive.csv").Close SaveChanges:=False


End Sub

基本上我正在寻找开放链接(经理)的最终人员的零干预,即使他精通技术。想法的情况是,他打开主电子表格,打开所有其他CSV文件,更新数据,然后关闭CSV文件并打开主表单并打开顶部,不要警告他"我们不能立即更新工作簿中的一些链接"

0 个答案:

没有答案