Excel VBA automation - Search and replace question

Rx_

Nothing In Moderation
Local time
Today, 04:24
Joined
Oct 22, 2009
Messages
2,803
Wondering if a global search and replaces would be in order?
The problem is some random errors with the Excel application object.

Each of about 30 report functions begin with:
320 If ObjXL Is Nothing Then
330 Set ObjXL = New excel.Application

From this point, the ObjXL is used through out the code:
e.g. ObjXL.EnableEvents = False
ObjXL.Range("I5").Select

But past programmers have sprinkled code in the following format:
ObjXL.Application.CutCopyMode = False
ObjXL.Application.DisplayAlerts = False
ObjXL.Application.Calculation = xlAutomatic

While this appears to work the vast majority of the time, the home-made error logging shows that there are random failures related to the Application object.

Can anyone think of a reason that a global application search and replace of
ObjXL.Application replaced with ObjXL
could be a problem?
 
Just a followup, maybe someone can point out why:
This morning, after a global search and replace for ObjXL.Application to--> ObjXL.
no problems except for the following.

The vba code causing the error shown in the next reply is:
2990 ObjXL.Application.Left = 4
3000 ObjXL.Application.Top = -7.25

Changed to:
2990 ObjXL.Left = 4
3000 ObjXL.Top = -7.25

Still had an error if the front end database is run from a network location.
It works if the same database is copied and run from my workstation.

Once these two lines are commented out, there are no errors.

Error.Description in custom error trapping log (record error, err.clear, resume next)
Method 'Left' of object '_Application' failed
Method 'Top' of object '_Application' failed
 

Users who are viewing this thread

Back
Top Bottom