VBA
Discuss AutoCAD ActiveX and VBA (Visual Basic for Applications) questions here.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Need help with VB for Outlook Journaling & 2005

2 REPLIES 2
Reply
Message 1 of 3
Anonymous
163 Views, 2 Replies

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.
2 REPLIES 2
Message 2 of 3
nelson_ortiz
in reply to: Anonymous

i tried this one
Message 3 of 3
mikeshr2
in reply to: Anonymous

You are too kind Nelson. Posting an attached exe file with no explanation for what it does whatsoever. I after many weeks of struggle finally got this autojournal to record only the start time of the drawing. And looking at the VB code thats all it is designed to do. While it's not what sandsrfr is trying to do it is way way better than nothing. So will you please tell if running that .exe file will do what sandsrfr is trying to do, will it reset autojournal to not working and send me back to square one with it, set me up the same way it is now, or turn me into disgruntled gunman taking down every Nelson Ortiz in the phonebook.

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

Post to forums  

Autodesk Design & Make Report

”Boost