Avatar of hardycross
hardycross
 asked on

Getting run time error on some Win7 computers but not others with VB runtime

Run-time error 2147319765 (8002802b)  Automation error Element no found

I use visual basic 6 in windows 7 to operates outside of an autocad 2007 program.  My visual basic program works perfectly well on some identical computers but throws the error noted above on two other similar computers!

The project is referenced to Autocad 2007 Type Library.

The program I wrote simply requests an autocad screen then asks the user to select a polyline.  The error then appears in the line highlighted in my code below:

Private Sub Command1_Click()
Dim plobj As AcadLWPolyline
Dim ssetObj As AcadSelectionSet
Dim myapp As AcadApplication
Dim mydoc As AcadDocument
Dim i As Long
Dim ent As AcadObject
Dim ppt As Variant
Dim pcount As Long
Dim clObj As AcadLWPolyline

On Error GoTo err:

''List2.Clear
''List3.Clear
''List4.Clear
''List5.Clear
''List6.Clear
''List7.Clear
''
''List8.Clear
''List9.Clear
''
''Grid1.Clear
''Text1.Text = ""
''
''On Error GoTo err:

Set myapp = GetObject(, "Autocad.application")
Set mydoc = myapp.ActiveDocument

    If mydoc.SelectionSets.Count > 0 Then
    mydoc.SelectionSets(0).Delete
    End If

Set ssetObj = mydoc.SelectionSets.Add("sent")

On Error Resume Next
AppActivate ("Autocad")
    If err Then
    Me.Show
    MsgBox "Is Autocad Runnning - it should be!", vbOKOnly, App.Title
    Exit Sub
    End If
            
On Error Resume Next

myapp.ActiveDocument.Utility.GetEntity ent, ppt, "Select Centerline: "[u] ***********************************************ERROR HERE*******************[/u]
    If err Then
    Me.Show
    MsgBox "Nothing Selected1"
    Exit Sub
    End If

Open in new window


-------------------------------------------------- more code below that I can send but seems not to be at issue ---------------------------
Windows 7Visual Basic Classic* AutoCAD

Avatar of undefined
Last Comment
hardycross

8/22/2022 - Mon
irudyk

Just curious, doesn't the ent object have to be set first?
Martin Liss

I added CODE tags around your code to make it easier to read.

I see you refer to ActiveDocument and if this is really VB6, that's not right.
irudyk

I'd think ActiveDocument would be valid since I'd assume it's an existing object within the AutoCad API.
Your help has saved me hundreds of hours of internet surfing.
fblack61
Martin Liss

Why is line 46 there? Try changing it to On Error GoTo 0.
Martin Liss

I'd think ActiveDocument would be valid since I'd assume it's an existing object within the AutoCad API.
You seem to be correct.

I know nothing about AutoCAD but here's an example from AutoDesk documentation that seems to be a little different than what the Asker has in his code.

Sub Example_ActiveDocument()
    Dim activeDoc As AcadDocument
    ' Returns current document in AutoCAD
    Set activeDoc = ThisDrawing.Application.ActiveDocument
    MsgBox "The active document is: " & activeDoc.name, vbInformation, "ActiveDocument Example"
End Sub

Open in new window

hardycross

ASKER
To my helpers :  The exact same code works on other computers.  It is not the Code that is the issue - I think it has to be in something within the computer -- possibly the registry -- or registered components.
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
irudyk

Okay, then I'd try doing an installation repair of the AutoCAD program on the computers that have the problem to see if that fixed it.
hardycross

ASKER
Here is a screen capture from my other computer -running the exact same file - it works to populate the list boxes after selecting a polyline object.
hardycross

ASKER
Unfortunately, re-installing autocad is a heavy weight since the program version is  a few releases ago.  I was hoping to find a solution  in screen time.
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy
irudyk

I suppose trying to just do a "repair" of the program is not an option under Windows | Apps & features
irudyk

You may also want to look at Repairing only the registry settings for AutoCAD Architecture to see if those instructions are applicable.
Martin Liss

The exact same code works on other computers.
Okay, understood, but do they all run the exact same version of AutoCad?
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
hardycross

ASKER
exact same versions of autocad 2007.  The more I try to figure this out the stranger it gets.  I can get past the error line now by changing the line:

Dim ent as AcadObject ; to;  Dim plEnt As Object -- the screen selection takes places as programmed bu then later in the flow the object 'plent won't give up its coordinates programmatically - even though they are visible on the watch window as coordinates.
Screen_Cap_2.jpg
irudyk

Were you not able to repair the registry entries from the link provided?
hardycross

ASKER
the link is for autocad architecture - a more modern program than autocad 2007
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck
Martin Liss

Okay, last question. Do all the computers have Windows 7 Service Pack 1 (SP1) installed?
ASKER CERTIFIED SOLUTION
irudyk

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
hardycross

ASKER
just downloaded SP2 - will take some time to see if it works - tx
hardycross

ASKER
Thanks- I had to rework some code but the SP2 installation seems to have cleared up 99% of the problems - thanks again.
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.