关于用ole把dw导入到excel的出错处理,该怎么解决

关于用ole把dw导入到excel的出错处理
我是这么写的,但是用fileopen判断时如果不满足就会新建一个空的excel,把原来已经存在的excel的数据给冲掉了,谁有比较好的判断方法?
//3.同名文件存在与否判断
if FileExists(ls_path) then
li_FileNum = FileOpen(ls_path, StreamMode!, Write!, LockReadWrite! , Replace!) 
if li_FileNum = -1 then
MessageBox('Microsoft Excel',"在当前位置发现名为"+ls_path+"的文件已经打开,请先关闭该文件!")
return 0
end if
FileClose(li_FileNum)
if MessageBox('Microsoft Excel',"在当前位置发现已经存在名为"+ls_path+"的文件,您希望将该文件替换吗",&
Information! ,YesNoCancel! ,3) = 1 then
FileDelete(ls_path)
else
return 0
end if
end if

------解决方案--------------------
发段vb代码给你,你转换一下就可以了~~
Private Declare Function lOpen()Function lOpen Lib "kernel32" Alias "_lopen" (ByVal lpPathName As String, ByVal iReadWrite As Long) As Long
Private Declare Function lClose()Function lClose Lib "kernel32" Alias "_lclose" (ByVal hFile As Long) As Long

' 判断某文件是否在使用中
Public Function IsFileAlreadyOpen()Function IsFileAlreadyOpen(ByVal FileName As String) As Boolean
Dim hFile As Long
Dim lastErr As Long
hFile = -1 ' 初始化文件句柄.
lastErr = 0
hFile = lOpen(FileName, &H10)

If hFile = -1 Then ' 文件是否能正确打开并可共享
lastErr = Err.LastDllError
Else
lClose(hFile)
End If
IsFileAlreadyOpen = (hFile = -1) And (lastErr = 32)
End Function

Private Sub Command1_Click()Sub Command1_Click()
Dim strFileName As String
strFileName = "d:\050304_chengji.xls" ' 你的文件
If IsFileAlreadyOpen(strFileName) Then
MsgBox("指定文件已打开")
Else
MsgBox("指定文件未打开")
End If
End Sub