AutoCAD有时将盘符大写.
加了Lcase函数应该可以:
- Private Sub cmddo_click()
- On Error Resume Next
- Size = 0
- If File1.ListCount = 0 Then Exit Sub
- Set AcadApp = GetObject(, "AutoCAD.application")
- If Err Then
- NewApp = True
- Err.Clear
- Set AcadApp = CreateObject("AutoCAD.application")
- If Err Then
- MsgBox Err.Description
- Exit Sub
- End If
- End If
- If Right(Dir1.Path, 1) <> "" Then
- Path = Dir1.Path & ""
- Else
- Path = Dir1.Path
- End If
- For i = 0 To File1.ListCount - 1 Step 1
- If File1.Selected(i) Then '对列表文件进行处理
- a = Path + File1.List(i)
- File1.Selected(i) = False
- AcadApp.documents.open a
- If Err Then
- Err.Clear
- MsgBox Err.Description
- End If
- On Error GoTo 0 '关闭错误陷井,以便调试后续语句.
- For Each CurDoc In AcadApp.documents
- If LCase(CurDoc.FullName) = LCase(a) Then
- CurDoc.PurgeAll
- CurDoc.PurgeAll
- CurDoc.PurgeAll
- CurDoc.PurgeAll
- OutFileName = Path & "S_" & File1.List(i)
- If Dir(OutFileName) = "" Then
- CurDoc.SaveAs OutFileName
- ElseIf MsgBox("文件已经存在:" & vbCrLf & OutFileName & vbCrLf & "要替换它吗?", vbYesNo) = vbYes Then
- CurDoc.SaveAs OutFileName
- End If
- CurDoc.Close
- Size = Size + FileLen(OutFileName)
- Exit For
- End If
- Next CurDoc
- End If
- Next i
- Text2.Text = Str(Size)
- If NewApp = True Then AcadApp.quit
- File1.Refresh
- Set AcadApp = Nothing
- End Sub
|