I grabbed someone's script from the forum, but it wasn't working properly.
I'm trying to modify this so that it will record the start time, end time (ie: duration in outlook journal) for documents when they are closed.
Currently, it is doing this when a document is saved, which isn't bad, but it is also making a new entry everytime you hit save.
I'd rather have it just make an entry when you 'close' a drawing. But I've made every attempt at it (being a newbie to VB) and have had no luck.
Can anyone help in modifying this to just make an entry in outlook/journal when a drawing is closed that includes:
start time, end time (duration), file name, file location (path).
TIA.
This is how I have the code modified so far:
Option Explicit
Public WithEvents ACADApp As AcadApplication
Public MyOlApp As Object
Public MyOlItem As Object
Public MyTime As String
Public MyTimeEnd As String
Public Body As String
Sub AcadStartUp()
Set ACADApp = GetObject(, "AutoCAD.Application")
MyTime = Date + Time
ThisDrawing.SummaryInfo.AddCustomInfo "TimeStart", MyTime
ThisDrawing.SummaryInfo.SetCustomByKey "TimeStart", MyTime
End Sub
Private Sub ACADApp_BeginSave(ByVal FileName As String)
MyTimeEnd = Date + Time
ThisDrawing.SummaryInfo.AddCustomInfo "TimeEnd", MyTimeEnd
ThisDrawing.SummaryInfo.SetCustomByKey "TimeEnd", MyTimeEnd
Set MyOlApp = CreateObject("Outlook.Application")
Set MyOlItem = MyOlApp.CreateItem(olJournalItem)
MyOlItem.Type = "AutoCad"
ThisDrawing.SummaryInfo.GetCustomByKey "TimeStart", MyTime
MyOlItem.Start = MyTime
ThisDrawing.SummaryInfo.GetCustomByKey "TimeEnd", MyTimeEnd
MyOlItem.End = MyTimeEnd
While (ThisDrawing.SummaryInfo.NumCustomInfo >= 1)
ThisDrawing.SummaryInfo.RemoveCustomByIndex 0&
Wend
End Sub
Private Sub ACADApp_EndSave(ByVal FileName As String)
ThisDrawing.SummaryInfo.AddCustomInfo "TimeStart", MyTime
MyOlItem.Subject = ThisDrawing.GetVariable("dwgname")
Body = Body + "Drawing: " + ThisDrawing.Name + vbCr
Body = Body + "Drawing folder: " + ThisDrawing.Path + vbCr
MyOlItem.Body = Body
MyOlItem.Categories = "AutoCAD Drawing," + ThisDrawing.GetVariable("loginname") + "," + ThisDrawing.Path
MyOlItem.Save
End Sub
The attachment is the original file that I grabbed from these forums and modified.