natan.zimand@gmail.com
Guest
|
Posted:
Thu May 12, 2005 12:10 am Post subject:
running a macro before closing a drawing |
|
|
I found a little snippet of code that adds a journal entry to Outlook
every time a drawing is opened or closed.
it looks like this:
Sub ad_OpenDwg()
'Demand load: -vbarun;ad_OutlookJournal.dvb!ad_OpenDwg;
'Creates a Journal entry in the format:
' FullDwgPath -OPENED- CurrentSystemTime
Dim adOutlookApp As Object
Dim adCadItem As Object
Dim adJournalEntryName As String
Dim adSysStart As Variant
adSysStart = Time
adJournalEntryName = ThisDrawing.FullName
If adJournalEntryName <> "" Then
Set adOutlookApp = CreateObject("Outlook.Application")
Set adCadItem = adOutlookApp.CreateItem(olJournalItem)
With adCadItem
.Type = "AutoCAD"
.Subject = adJournalEntryName & " -OPENED- " & adSysStart
.StartTimer
.Save
End With
End If
End Sub
Sub ad_CloseDwg()
'Demand load: -vbarun;ad_OutlookJournal.dvb!ad_CloseDwg;
'Creates a Journal entry in the format:
' FullDwgPath -CLOSED- CurrentSystemTime
Dim adOutlookApp As Object
Dim adCadItem As Object
Dim adJournalEntryName As String
Dim adSysEnd As Variant
adSysEnd = Time
adJournalEntryName = ThisDrawing.FullName
If adJournalEntryName <> "" Then
Set adOutlookApp = CreateObject("Outlook.Application")
Set adCadItem = adOutlookApp.CreateItem(olJournalItem)
With adCadItem
.Type = "AutoCAD"
.Subject = adJournalEntryName & " -CLOSED- " & adSysEnd
.StartTimer
.Save
End With
End If
End Sub
so you can see it has two macros ad_opendwg and ad_closedwg. I have
gotten the ad_opendwg to run from my s::startup in my acaddoc.lsp file,
which makes it run every time i start a new file. but i am trying to
call the ad_closedwg every time i exit a drawing. I have tried
changing the acad.mnu file , like this:
ID_DWG_CLOSE [&Close]^C^C(command "-vbarun" "ad_closeDwg")_close
but it doesn't work.
I am looking for any advice that anyone can give me to call this macro
on exiting a file. Also, is there any way to get this macro to work if
you hit the window close X in the top right corner?
Thanks for your help.
|
|