We help IT Professionals succeed at work.

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

166 Views
Last Modified: 2019-02-11
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 ---------------------------
Comment
Watch Question

CERTIFIED EXPERT
Top Expert 2008

Commented:
Just curious, doesn't the ent object have to be set first?
Martin LissSocial distance - Don't touch your face - Wash your hands for 20 seconds
CERTIFIED EXPERT
Most Valuable Expert 2017
Distinguished Expert 2018

Commented:
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.
CERTIFIED EXPERT
Top Expert 2008

Commented:
I'd think ActiveDocument would be valid since I'd assume it's an existing object within the AutoCad API.
Martin LissSocial distance - Don't touch your face - Wash your hands for 20 seconds
CERTIFIED EXPERT
Most Valuable Expert 2017
Distinguished Expert 2018

Commented:
Why is line 46 there? Try changing it to On Error GoTo 0.
Martin LissSocial distance - Don't touch your face - Wash your hands for 20 seconds
CERTIFIED EXPERT
Most Valuable Expert 2017
Distinguished Expert 2018

Commented:
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

Author

Commented:
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.
CERTIFIED EXPERT
Top Expert 2008

Commented:
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.

Author

Commented:
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.

Author

Commented:
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.
CERTIFIED EXPERT
Top Expert 2008

Commented:
I suppose trying to just do a "repair" of the program is not an option under Windows | Apps & features
CERTIFIED EXPERT
Top Expert 2008

Commented:
You may also want to look at Repairing only the registry settings for AutoCAD Architecture to see if those instructions are applicable.
Martin LissSocial distance - Don't touch your face - Wash your hands for 20 seconds
CERTIFIED EXPERT
Most Valuable Expert 2017
Distinguished Expert 2018

Commented:
The exact same code works on other computers.
Okay, understood, but do they all run the exact same version of AutoCad?

Author

Commented:
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
CERTIFIED EXPERT
Top Expert 2008

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

Author

Commented:
the link is for autocad architecture - a more modern program than autocad 2007
Martin LissSocial distance - Don't touch your face - Wash your hands for 20 seconds
CERTIFIED EXPERT
Most Valuable Expert 2017
Distinguished Expert 2018

Commented:
Okay, last question. Do all the computers have Windows 7 Service Pack 1 (SP1) installed?
CERTIFIED EXPERT
Top Expert 2008
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION

Author

Commented:
just downloaded SP2 - will take some time to see if it works - tx

Author

Commented:
Thanks- I had to rework some code but the SP2 installation seems to have cleared up 99% of the problems - thanks again.
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.