Private Sub Workbook_open() ' '--- Define variables. ' Dim strFileG As String Dim strFileI As String Dim strFileL As String Dim ExcelFile As Excel.Workbook ' '--- Handle C:/TEMP/MIS/Report/TMP0046701.xls ' OpenFile "C:/TEMP/MIS/Report/TMP0046701.xls" ' '--- Handle C:/TEMP/MIS/Report/P00467_Form.xls. ' Add "C:/TEMP/MIS/Program/P00467_Form.xls", "C:/TEMP/MIS/Report/TMP0046701.xls" ' '--- Save C:/TEMP/MIS/Report/P00467_Form.xls. ' Application.ScreenUpdating = False Set ExcelFile = Workbooks.Open("C:/TEMP/MIS/Program/P00467_Form.xls", UpdateLinks:="3") strFileG = "C:/TEMP/MIS/Report/P00467_" + Format(Date, "yyyymmdd") + Format(Time, "hhmmss") ExcelFile.SaveAs (strFileG) Set ExcelFile = Nothing End Sub Private Sub OpenFile(FileN As String) Dim xlsFile As Excel.Workbook If Len(Dir(FileN, vbDirectory)) > 0 Then Application.ScreenUpdating = False Set xlsFile = Workbooks.Open(FileName:=FileN) xlsFile.Save xlsFile.Close SaveChanges:=True Set xlsFile = Nothing End If End Sub Private Sub Add(FileN1 As String, FileN2 As String) Dim xlsFile1 As Excel.Workbook Dim xlsFile2 As Excel.Workbook If Len(Dir(FileN2, vbDirectory)) > 0 Then ' '--- Insert data. ' Application.ScreenUpdating = False Set xlsFile1 = Workbooks.Open(FileName:=FileN1, UpdateLinks:="3") Set xlsFile2 = Workbooks.Open(FileName:=FileN2) Application.Goto Reference:="R2C1" Range("A2:H600").Select Selection.Copy xlsFile1.Sheets("Spreadsheet").Paste Destination:=xlsFile1.Sheets("Spreadsheet").Range("A4") Application.CutCopyMode = False ' Range("K2:K2").Select Selection.Copy xlsFile1.Sheets("Spreadsheet").Paste Destination:=xlsFile1.Sheets("Spreadsheet").Range("D2") Application.CutCopyMode = False ' Range("J2:J2").Select Selection.Copy xlsFile1.Sheets("Spreadsheet").Paste Destination:=xlsFile1.Sheets("Spreadsheet").Range("F2") Application.CutCopyMode = False ' xlsFile2.Close SaveChanges:=True Set xlsFile2 = Nothing ' '--- Format data. ' Application.ScreenUpdating = False xlsFile1.Worksheets("Spreadsheet").Select xlsFile1.Worksheets("Spreadsheet").Range("A1:H65536").Columns.AutoFit ' Range("D2:D2").Select With Selection.Interior .ColorIndex = 4 .Pattern = xlSolid End With Range("F2:F2").Select With Selection.Interior .ColorIndex = 4 .Pattern = xlSolid End With ' Range("A4:G600").Select With Selection .HorizontalAlignment = xlCenter .VerticalAlignment = xlCenter .WrapText = False .Orientation = 0 .AddIndent = False .ShrinkToFit = False .MergeCells = False End With ' '--- Close files. ' xlsFile1.Close SaveChanges:=True Set xlsFile1 = Nothing End If End Sub