2013年2月1日 星期五

[Visual Basic] Refresh All




Imports Excel = Microsoft.Office.Interop.Excel

Module Module1

    Sub Main()
        Dim oExcel As Excel.Application
        Dim oWorkbook As Excel.Workbook
        Dim oWorksheet As Excel.Worksheet

        oExcel = CreateObject("Excel.Application")
        oExcel.Visible = True
        oExcel.DisplayAlerts = False

        oWorkbook = oExcel.Workbooks.Open("test.xlsm")
        oWorkbook.RefreshAll()
        oWorkbook.Save()
        oWorkbook.Close()
        oExcel.Quit()

    End Sub

End Module

沒有留言: