|
access调用excel打开2个文件比较,可是文件名不能相同,怎么解决?即使文件路径不同也不行,文件名还必须不同,我怎么把名称自动改掉一个呢? 代码如下:
Dim babe As Object
Dim i As Integer
Dim j As Integer
Set babe = CreateObject("Excel.application")
babe.Visible = True
Set baby1 = babe.workbooks.Open(Me!Text0.Value)
Set baby2 = babe.workbooks.Open(Me!Text2.Value)
With baby1
For i = 1 To 300
For j = 1 To 30
If .Sheets(1).Cells(i, j) <> baby2.Sheets(1).Cells(i, j) Then
baby2.Sheets(1).Cells(i, j).Font.Color = RGB(0, 255, 0)
baby2.Sheets(1).Cells(i, j).Font.Size = 20
End If
Next
Next
.Save
baby2.Save
End With
babe.Quit
Set babe = Nothing
MsgBox "The comparision has finished. The result was saved in your second file"
还有个问题,我如果是打开xls文件,可以自动保存不提示,可是我比较CSV文件的时候,他会跳出来对话框问我是否要保存,我上面的.SAVE为什么不起作用了?如何解决?谢谢 |
|