Private Sub mnu_文件另存为_Click() Dim key1 As Integer Dim i As Integer, k As Integer On Error GoTo err0 CommonDialog1.Filter = "AutoCAD文件(*.dwg)|*.dwg|" & "全部文件(*.*)|*.*|" CommonDialog1.CancelError = True CommonDialog1.DialogTitle = "另存为"
CommonDialog1.ShowSave File_保存文件.Path = CurDir File_保存文件.Pattern = "*.dwg" k = 0 For i = 0 To File_保存文件.ListCount - 1 If LCase(CommonDialog1.FileName) = LCase(File_保存文件.Path & "\" & File_保存文件.List(i)) Then k = 1 Exit For End If Next i If k = 1 Then key1 = MsgBox("该文件已存在,是否要替换", vbYesNo + vbQuestion, "保存文件") Select Case key1 Case vbNo 'CommonDialog1.filename = "" Exit Sub Case vbYes filename0 = CommonDialog1.FileName End Select Else filename0 = CommonDialog1.FileName acadApp.activedocument.SaveAs File_保存文件.Path & "\" & filename0 & ".dwg" End If End Sub |