.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Need help with VB for Outlook Journaling & 2005

1 REPLY 1
Reply
Message 1 of 2
sandsrfr
173 Views, 1 Reply

Need help with VB for Outlook Journaling & 2005

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.
1 REPLY 1
Message 2 of 2
Anonymous
in reply to: sandsrfr

I would really like to get this working as well. i succesfully managed it in
microstation but that was easier to trap the open/close events as it is a
SDI rather than autocad that can multiple drawings open at once.

have you got anywhere with this?

russ

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost