|
楼主 |
发表于 2009-2-2 23:05
|
显示全部楼层
Sub auto_open()
Attribute auto_open.VB_ProcData.VB_Invoke_Func = " \n14"
Caption
average2
Sheet1ontime
daysave
End Sub
Sub Caption()
Attribute Caption.VB_ProcData.VB_Invoke_Func = " \n14"
Dim fname As String
Dim sday As String
Dim smonth As String
Dim syear As String
'Sheets(1).Range("B5:T28").ClearContents
'Sheets(2).Range("B5:AG28").ClearContents
sday = Trim(Str(Day(Date)))
If Len(sday) = 1 Then
sday = " " + sday
End If
smonth = Trim(Str(Month(Date)))
If Len(smonth) = 1 Then
smonth = " " + smonth
End If
syear = Trim(Str(Year(Date)))
' Application.Caption = "净水厂"
Application.Caption = "日报表"
Application.WindowState = xlMaximized
Sheets(1).Select
Range("M1").Select
ActiveCell.FormulaR1C1 = " " + syear + "年" + smonth + "月" + sday + "日"
Sheets(2).Select
Range("O1").Select
ActiveCell.FormulaR1C1 = " " + syear + "年" + smonth + "月" + sday + "日"
Sheets(2).Select
Range("AG1").Select
ActiveCell.FormulaR1C1 = " " + syear + "年" + smonth + "月" + sday + "日"
Sheets(1).Select
Cells(1, 1).Select
End Sub
Sub daysave()
Attribute daysave.VB_ProcData.VB_Invoke_Func = " \n14"
Application.OnTime TimeValue("0:00:30"), "save_month_as"
Application.OnTime TimeValue("0:01:00"), "save_copy_as"
End Sub
Sub save_copy_as()
Attribute save_copy_as.VB_ProcData.VB_Invoke_Func = " \n14"
Dim fname As String
Dim sday As String
Dim smonth As String
Dim syear As String
sday = Trim(Str(Day(Date - 1)))
If Len(sday) = 1 Then
sday = "0" + sday
End If
smonth = Trim(Str(Month(Date - 1)))
If Len(smonth) = 1 Then
smonth = "0" + smonth
End If
syear = Trim(Str(Year(Date - 1) + 8))
fname = "c:\project\report\" + syear + smonth + sday + ".xls"
Sheets(1).Select
Workbooks.Open(filename:="c:\project\report\DAY1_TMP.XLS").RunAutoMacros which:=xlAutoOpen
'Sheet 1 operation
Windows("day1.XLS").Activate
Sheets(1).Select
Range("B5:M31").Select
Selection.Copy
Windows("day1_TMP.XLS").Activate
Sheets(1).Select
Range("B5").Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Range("A1").Select
Sheets(1).Select
Range("M1").Select
ActiveCell.FormulaR1C1 = " " + syear + "年" + smonth + "月" + sday + "日"
'Sheet 2 operation
Windows("day1.XLS").Activate
Sheets(2).Select
Range("B5:O31").Select
Selection.Copy
Windows("day1_TMP.XLS").Activate
Sheets(2).Select
Range("B5").Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Sheets(2).Select
Range("O1").Select
ActiveCell.FormulaR1C1 = " " + syear + "年" + smonth + "月" + sday + "日"
'Sheet 3 operation
Windows("day1.XLS").Activate
Sheets(2).Select
Range("P5:AG31").Select
Selection.Copy
Windows("day1_TMP.XLS").Activate
Sheets(3).Select
Range("B5").Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Sheets(3).Select
Range("S1").Select
ActiveCell.FormulaR1C1 = " " + syear + "年" + smonth + "月" + sday + "日"
'Day save and print operation
Application.CutCopyMode = False
ActiveWorkbook.SaveAs filename:=fname, FileFormat:=xlNormal, _
Password:="", WriteResPassword:="", ReadOnlyRecommended:=False _
, CreateBackup:=False
Sheets(1).Select
ActiveSheet.PrintOut
Sheets(2).Select
ActiveSheet.PrintOut
Sheets(3).Select
ActiveSheet.PrintOut
ActiveWorkbook.Close
Range("A1").Select
Workbooks.Open(filename:="c:\project\report\TEMP1.XLS").RunAutoMacros which:=xlAutoOpen
'Windows("day1.XLS").Activate
End Sub |
|