K
Kenneth Courville
Using MS Article 302901 for assistance, I have built a MS Access 2002
add-in. The only problem seems to be that MSACCESS.EXE process seems
to not close properly upon exiting Access.
My goal here is to have the add-in launch upon opening Access and wait
for an Access project to be opened (either ADP or ADE extension). The
method I'm trying is to use a System.Timers.Timer object, which checks
for this every .5 second. Once a Access project is detected, the
add-in builds a new command bar with a button on it.
My timer_Elasped event is shown below. The code I've isolated the
problem to is marked with arrows.
I've found that if any Access exceptions are caused by the add-in...
even if handled... the ACCESS process will not close. So far, the
only property I found that will not throw an exception if a project
isn't open yet is Application.Forms.Count, but this seems to cause the
process to hang as well.
Maybe my problem is that I need a better way to check if a project is
loaded yet.
private void timer_Elapsed(object sender, ElapsedEventArgs e)
{
string projectName = "";
// Get project name
// If no name exists yet, set project name to a blank value
try
{
--> if( applicationObject.Forms.Count > 0 ) // Check if a project
is open yet
--> {
--> projectName = applicationObject.CurrentProject.Name;
--> }
--> else
--> projectName = "";
}
catch( Exception ex )
{
System.Diagnostics.Debug.WriteLine( ex.StackTrace );
projectName = "";
}
// If an Access Project is loaded, load the Access Manager Bar
if( projectName.ToUpper().EndsWith(COMPILED_PROJECT_EXTENSION) ||
projectName.ToUpper().EndsWith(PROJECT_EXTENSION) )
{
timer.Stop();
CreateCommandBar();
}
add-in. The only problem seems to be that MSACCESS.EXE process seems
to not close properly upon exiting Access.
My goal here is to have the add-in launch upon opening Access and wait
for an Access project to be opened (either ADP or ADE extension). The
method I'm trying is to use a System.Timers.Timer object, which checks
for this every .5 second. Once a Access project is detected, the
add-in builds a new command bar with a button on it.
My timer_Elasped event is shown below. The code I've isolated the
problem to is marked with arrows.
I've found that if any Access exceptions are caused by the add-in...
even if handled... the ACCESS process will not close. So far, the
only property I found that will not throw an exception if a project
isn't open yet is Application.Forms.Count, but this seems to cause the
process to hang as well.
Maybe my problem is that I need a better way to check if a project is
loaded yet.
private void timer_Elapsed(object sender, ElapsedEventArgs e)
{
string projectName = "";
// Get project name
// If no name exists yet, set project name to a blank value
try
{
--> if( applicationObject.Forms.Count > 0 ) // Check if a project
is open yet
--> {
--> projectName = applicationObject.CurrentProject.Name;
--> }
--> else
--> projectName = "";
}
catch( Exception ex )
{
System.Diagnostics.Debug.WriteLine( ex.StackTrace );
projectName = "";
}
// If an Access Project is loaded, load the Access Manager Bar
if( projectName.ToUpper().EndsWith(COMPILED_PROJECT_EXTENSION) ||
projectName.ToUpper().EndsWith(PROJECT_EXTENSION) )
{
timer.Stop();
CreateCommandBar();
}