Norman ,
Thank you for your comments. The title of my post is incorrect as SelectOnScreen is not creating the error, although it does create an error down the line since it did not allow the user to select anything. The line for "AppActivate ThisDrawing.Application.Caption" was added recently as I found it used in another post and gave it a try. I have removed the line and I'm still getting the same results. This code is written in AutoCAD VBA. You mentioned the code may be broken due to the update in Acad2015. That is probably the case and I would need to find another way to perform this task if it can't be fixed here.
What I have found is if I select only one drawing from my OpenDoc form the SelectOnScreen function works correctly. It is when I select more than one drawing that it doesn't allow me to select objects. Even though I have activated the current drawing.
I've cleaned up my code to only show what is needed to get past the SelectOnScreen issue (notice I didn't say error?)
I appreciate your assistance and knowledge,
Jack
Option Explicit
Public colDwgSel As New Collection '''drawings selected to open
Public oApp As AcadApplication
Public sPath As String
Private oDoc As AcadDocument
Private Response
Public Sub Wire()
Set oApp = AcadApplication
Set oDoc = oApp.ActiveDocument
sPath = oDoc.Path & "\"
'form to get unit type
Load FrmUnitType
FrmUnitType.show
'form to select drawings to open
Load FrmOpenDoc
FrmOpenDoc.show
Unload FrmUnitType
Unload FrmOpenDoc
' close all open drawings
For Each oDoc In oApp.Documents
Set oDoc = oApp.Documents.Item(0)
oDoc.Close
Next
'open all drawings selected in FrmOpenDoc
Dim DwgSel As Variant
For Each DwgSel In colDwgSel
oApp.Documents.Open DwgSel
Next
Set oDoc = oApp.Documents.Item(0)
'''call module to get devices in order to be wired
GetDevices
For Each oDoc In oApp.Documents
oDoc.Close True
Next
Set oDoc = Nothing
Set oApp = Nothing
End Sub
Private Sub GetDevices()
Dim drawing As AcadDocument
Dim sDwg As String
For Each drawing In ThisDrawing.Application.Documents
drawing.Activate
'call sub to select devices to be wired
GetSelections
Next drawing
Set drawing = Nothing
End Sub
Private Sub GetSelections()
Dim objDevices As AcadSelectionSet
Dim intCodes(0 To 0) As Integer
Dim varCodeValues(0 To 0) As Variant
intCodes(0) = 8 'set the code for layer
varCodeValues(0) = "DEVICE*" 'set the code value
On Error Resume Next
ThisDrawing.SelectionSets("DEVICES").Delete
On Error GoTo 0
Set objDevices = ThisDrawing.SelectionSets.Add("DEVICES")
'select only objects on device* layers
objDevices.SelectOnScreen intCodes, varCodeValues
If objDevices.Count > 0 Then
MsgBox "Selected " & objDevices.Count
Else
MsgBox "Was not prompted to select objects", vbOKCancel
End If
Set objDevices = Nothing
End Sub