'AfterOpenProject代码
With FileWatcher
.Path = "D:\Met\Reports"
.Filter = "*.xls"
.Delay = 1000
.Enabled = True
End With
'FileCreated 创建文件,
'以下代码在文件文件监视器FileCreated中没有达到预期效果
'如把 e.FullPath 换成 flur 放在命令窗口中是可以的!
Dim flur,pasw String
flur = "D:\Met\Reports\9.PPS Record 07 Jul 2014.xls"
pasW = "12345678"
If e.FullPath.ToUpper.Contains("PPS") AndAlso e.FullPath.ToUpper.Contains(".XLS") Then
Ap01 = New MSExcel.Application
Wb01= Ap01.WorkBooks.Open(e.FullPath,,True,,pasw)
Ws01= Wb01.WorkSheets("Data")
Ws01.AutoFilterMode = False
If Ws01.cells(1,1).Value =Nothing Then
Ws01.Rows(1).Delete(MSExcel.XlDirection.xlUp) '下面的单元格上移
End If
If Ws01.cells(2,9).Value =Nothing Then Ws01.cells(2,9).Value = 0
If Ws01.cells(2,10).Value =Nothing Then Ws01.cells(2,10).Value = 0
If Ws01.cells(2,12).Value =Nothing Then Ws01.cells(2,12).Value = 0
wb01.saveAs("D:\Met\PPS.xls") '没有执行
Ap01.Quit
FileSys.DeleteFile(e.FullPath,2,2) '没有执行
End If
[此贴子已经被作者于2014-7-8 15:57:43编辑过]