running a macro before closing a drawing
CADForums.net Forum Index CADForums.net
Discussion of AutoCAD and other CAD software.
 
 FAQFAQ   MemberlistMemberlist     RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 
Google
 
Web cadforums.net
running a macro before closing a drawing

 
Post new topic   Reply to topic    CADForums.net Forum Index -> VBA
Author Message
natan.zimand@gmail.com
Guest





Posted: Thu May 12, 2005 12:10 am    Post subject: running a macro before closing a drawing Reply with quote

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.

Back to top
 
Post new topic   Reply to topic    CADForums.net Forum Index -> VBA All times are GMT
Page 1 of 1

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum




Windows Server DSP VoIP Electronics New Topics
Powered by phpBB