Message 1 of 5
vba lockup

Not applicable
01-06-2002
11:20 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I have modified Autojournal (from autojournal.net, free source code
download) for my use. I simply changed it so that it did not have to track
time of use for each document but merely when a document was opened. I will
work on the time tracking if I can get this to work.
I used the following code with a sub of AcadStartup that merely initializes
the AcadApplication Events. Everything seems to work fine if I run the macro
"AcadStartup" at the command line after starting Acad 2000. Every following
document is logged in the Outlook Journal.
My problem is that when I put the line (command "-vbarun" "acadstartup") at
the end of acad2000.lsp or acad2000doc.lsp the module locks me up. Acad acts
as though there is a command in process but I cannot do anything. When I
type at the command prompt the curser moves over like text is being typed
but nothing appears on screen. I cannot escape out of the command not
execute and menu command. When I attempt to exit Acad I am told that a
command is in process and I need to exit the command before I can exit Acad.
I have to force Acad to exit by using the task manager.
Here's an even weirder twist. The code is set to skip any "Drawing*"
documents as I do not want any new documents logged, only saved documents so
when Acad is started with the (command "-vbarun" "acadstartup") in the
acad2000doc.lsp it will not
lock up until I open another document. So after initially starting Acad I
bring up the vba editor, toggle a breakpoint to follow the code and then
everything works just fine. No lockup! I am at a loss as to how to
troubleshoot this. Any Ideas?
--
Joel
joel@NSPM.harden-assoc.com
remove the NSPM. to email me directly
'''
'''
Public WithEvents ACADApp As AcadApplication ' Use with Application Event
Examples
'''
''' using outlook - be sure to go to Tools > References
''' and add the Microsoft Outlook library to the project
'''
Public oOutlookApp As Outlook.Application
Public oJournal As Outlook.JournalItem
'''
''' declare a couple of variables for managing the journal
'''
Private strFilename As String
Sub AcadStartup()
' This example intializes the public variable (ACADApp) which will be
used
' to intercept AcadApplication Events
'
' The VBA WithEvents statement makes it possible to intercept an generic
Object
' with the events associated with that object.
'
' Before you will be able to trigger any of the AcadApplication events,
' you will first need to run this procedure.
' We could get the application from the ThisDocument object, but that
would
' require having a drawing open, so we grab it from the system.
Set ACADApp = GetObject(, "AutoCAD.Application")
End Sub
Private Sub ACADApp_EndOpen(ByVal FileName As String)
''get documents name
strFilename = ThisDrawing.Name
'' exit if no document name
If strFilename = "" Then Exit Sub
'' exit if this is a new drawing
If strFilename Like "Drawing*" Then Exit Sub
'' start a new journal entry
StartJournal
End Sub
'''
''' start journal - helper routine
'''
Private Sub StartJournal()
'' get the outlook application
Set oOutlookApp = CreateObject("Outlook.Application")
'' create a new journal entry
Set oJournal = oOutlookApp.CreateItem(olJournalItem)
'' set the category, and start timing
With oJournal
.Subject = strFilename
.Type = "AutoCAD"
.Save
End With
End Sub
download) for my use. I simply changed it so that it did not have to track
time of use for each document but merely when a document was opened. I will
work on the time tracking if I can get this to work.
I used the following code with a sub of AcadStartup that merely initializes
the AcadApplication Events. Everything seems to work fine if I run the macro
"AcadStartup" at the command line after starting Acad 2000. Every following
document is logged in the Outlook Journal.
My problem is that when I put the line (command "-vbarun" "acadstartup") at
the end of acad2000.lsp or acad2000doc.lsp the module locks me up. Acad acts
as though there is a command in process but I cannot do anything. When I
type at the command prompt the curser moves over like text is being typed
but nothing appears on screen. I cannot escape out of the command not
execute and menu command. When I attempt to exit Acad I am told that a
command is in process and I need to exit the command before I can exit Acad.
I have to force Acad to exit by using the task manager.
Here's an even weirder twist. The code is set to skip any "Drawing*"
documents as I do not want any new documents logged, only saved documents so
when Acad is started with the (command "-vbarun" "acadstartup") in the
acad2000doc.lsp it will not
lock up until I open another document. So after initially starting Acad I
bring up the vba editor, toggle a breakpoint to follow the code and then
everything works just fine. No lockup! I am at a loss as to how to
troubleshoot this. Any Ideas?
--
Joel
joel@NSPM.harden-assoc.com
remove the NSPM. to email me directly
'''
'''
Public WithEvents ACADApp As AcadApplication ' Use with Application Event
Examples
'''
''' using outlook - be sure to go to Tools > References
''' and add the Microsoft Outlook library to the project
'''
Public oOutlookApp As Outlook.Application
Public oJournal As Outlook.JournalItem
'''
''' declare a couple of variables for managing the journal
'''
Private strFilename As String
Sub AcadStartup()
' This example intializes the public variable (ACADApp) which will be
used
' to intercept AcadApplication Events
'
' The VBA WithEvents statement makes it possible to intercept an generic
Object
' with the events associated with that object.
'
' Before you will be able to trigger any of the AcadApplication events,
' you will first need to run this procedure.
' We could get the application from the ThisDocument object, but that
would
' require having a drawing open, so we grab it from the system.
Set ACADApp = GetObject(, "AutoCAD.Application")
End Sub
Private Sub ACADApp_EndOpen(ByVal FileName As String)
''get documents name
strFilename = ThisDrawing.Name
'' exit if no document name
If strFilename = "" Then Exit Sub
'' exit if this is a new drawing
If strFilename Like "Drawing*" Then Exit Sub
'' start a new journal entry
StartJournal
End Sub
'''
''' start journal - helper routine
'''
Private Sub StartJournal()
'' get the outlook application
Set oOutlookApp = CreateObject("Outlook.Application")
'' create a new journal entry
Set oJournal = oOutlookApp.CreateItem(olJournalItem)
'' set the category, and start timing
With oJournal
.Subject = strFilename
.Type = "AutoCAD"
.Save
End With
End Sub