VBA sample

HomeHome BlogBlog TwitterTwitter YouTubeYouTube ContactContact
 
 
 

Blog Headlines


Subscribe to the blog


 
 

revert.dvb sample code for AutoCAD

I use this one for AutoCAD 2004 instead of the Express tools command Revert since it has a limit of 127 characters for the length of the path and file name.

'Ravi Pothineni 1/13/2003

'Modify the following lisp code to define you command to run the revert() macro.
'You need to change "c:/temp/" to the directory where this file is copied.
'(defun C:REVERTVBA ()
'  (acet-error-init '(("CMDECHO" 0)))
'  (vl-vbarun "c:/temp/revert.dvb!ThisDrawing.revert")
'  (acet-error-restore)
'  (princ)
')

Public Sub revert()
    If Documents.Count > 0 Then
        If ThisDrawing.GetVariable("DWGTITLED") = 1 Then
            If ThisDrawing.GetVariable("dbmod") > 0 Then
            
                Dim strName As String
                strName = ThisDrawing.FullName
                If MsgBox("Abandon changes to " & strName, vbOKCancel + vbExclamation + _
                          vbDefaultButton2, "AutoCAD - REVERT VBA") <> vbCancel Then
                    If AcadApplication.Preferences.System.SingleDocumentMode = False Then
                        ActiveDocument.Close False
                        Documents.Open strName
                    Else
                        ThisDrawing.Open strName
                    End If
                End If
            End If
        Else
            MsgBox "Drawing has never been saved.", vbCritical + vbOKOnly, "AutoCAD - REVERT VBA"
        End If
    End If
End Sub
 
© 2001-2013 JTB World. All rights reserved.