Link to home
Start Free TrialLog in
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 ---------------------------
Avatar of irudyk
irudyk
Flag of Canada image

Just curious, doesn't the ent object have to be set first?
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.
I'd think ActiveDocument would be valid since I'd assume it's an existing object within the AutoCad API.
Why is line 46 there? Try changing it to On Error GoTo 0.
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

Avatar of hardycross
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.
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.
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.
I suppose trying to just do a "repair" of the program is not an option under Windows | Apps & features
You may also want to look at Repairing only the registry settings for AutoCAD Architecture to see if those instructions are applicable.
The exact same code works on other computers.
Okay, understood, but do they all run the exact same version of AutoCad?
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
Were you not able to repair the registry entries from the link provided?
the link is for autocad architecture - a more modern program than autocad 2007
Okay, last question. Do all the computers have Windows 7 Service Pack 1 (SP1) installed?
ASKER CERTIFIED SOLUTION
Avatar of irudyk
irudyk
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
just downloaded SP2 - will take some time to see if it works - tx
Thanks- I had to rework some code but the SP2 installation seems to have cleared up 99% of the problems - thanks again.