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

hardycross
hardycross used Ask the Experts™
on
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

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2008

Commented:
Just curious, doesn't the ent object have to be set first?
Martin LissOlder than dirt
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.
Top Expert 2008

Commented:
I'd think ActiveDocument would be valid since I'd assume it's an existing object within the AutoCad API.
Ensure you’re charging the right price for your IT

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!

Martin LissOlder than dirt
Most Valuable Expert 2017
Distinguished Expert 2018

Commented:
Why is line 46 there? Try changing it to On Error GoTo 0.
Martin LissOlder than dirt
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.
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.
Top Expert 2008

Commented:
I suppose trying to just do a "repair" of the program is not an option under Windows | Apps & features
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 LissOlder than dirt
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
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 LissOlder than dirt
Most Valuable Expert 2017
Distinguished Expert 2018

Commented:
Okay, last question. Do all the computers have Windows 7 Service Pack 1 (SP1) installed?
Top Expert 2008
Commented:
Is the 2007 AutoCad updated to its Service Pack 2? If not, maybe try downloading that and the installation of SP2 might fix up any issues in the registry.

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.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial