Problem with Application object in VBA

367
1
01-23-2012 07:50 AM
SteveHempen
New Contributor
I have a .mxd file with VBA programmed by a long-gone programmer.  It uses the Application object.  The code worked fine in ArcGIS 9 and in 10 until recently.  The only changes made since the move to ver. 10 were schema changes in the data tables.
First error: ???Compile error: Method or data member not found??? occurred in the bolded code below:

Dim pMxDoc As IMxDocument
Dim pMap As IMap
Dim pFeatSel As IFeatureSelection
Dim pQueryFilt As IQueryFilter
Dim pSelSet As ISelectionSet
Dim pLayer As IFeatureLayer

Set pMxDoc = Application.Document
Set pMap = pMxDoc.FocusMap
Set pLayer = FindLayer("Parcels")
Set pFeatSel = pLayer

I changed Application .document to ThisDocument and it worked for that line of code, but then I got this error a few lines later:
???Compile error: Invalid use of property???  See bolded code below:

Dim pStatusBar As IStatusBar
Dim pProgbar As IStepProgressor

Set pStatusBar = Application.StatusBar
Set pProgbar = pStatusBar.ProgressBar
pProgbar.Position = 0


Any ideas?

There are no missing references.  Does the priority order of references make a difference?
0 Kudos
1 Reply
TimWhiteaker
Occasional Contributor II
Try this for a quick fix:

Set pStatusBar = ThisDocument.Parent.StatusBar


If Application appears in several more places, you could do something like the following, where you basically substitute pApp in place of Application:
Dim pApp As IApplication
Set pApp = ThisDocument.Parent

Set pStatusBar = pApp.StatusBar
0 Kudos