try this idea...
[code]
Sub test()
Dim ss As AcadSelectionSet
Dim ssName As String
ssName = "ss"
Set ss = ssAll(ssName)
If ss.Count <> 0 Then
ReDim objColl(ss.Count - 1) As Object
Dim i As Integer 'Long if necessary.
For i = 0 To ss.Count - 1
Set objColl(i) = ss(i)
Next i
End If
ss.Delete
End Sub
'Check dxf code 67 if you want paperspace entities.
Function ssAll(ssName As String) As AcadSelectionSet
ssDelete (ssName)
Set ssAll = ThisDrawing.SelectionSets.Add(ssName)
ssAll.Select acSelectionSetAll
End Function
Sub ssDelete(ssName As String)
On Error Resume Next
ThisDrawing.SelectionSets(ssName).Delete
End Sub
[/code]
wrote in message news:[email protected]...
Sub Example_Import()
Dim MyXL As Object ' Variable to hold reference
Dim MyXLSheet As Object
Dim r As Range
Dim n As Integer
Dim Acad As AcadApplication
Dim newdoc As AcadDocument
Dim oPref As AcadPreferencesOpenSave
Dim mode As Integer
Dim DOC0 As AcadDocument
Dim objCollection(0 To 1) As Object
Dim retObjects As Variant
Dim Drawing As AcadDocument
Dim DrawingCopy As AcadDocument
Dim Doc1MSpace As AcadModelSpace
Dim DOC1 As AcadDocument
'Opening Excel Sheet with drawings
Set MyXL = GetObject(, "Excel.Application")
Set MyXL = GetObject("G:\Probleem Tekeningen\macro_dwg_to_dwg.xls")
MyXL.Application.Visible = True
MyXL.Parent.Windows(1).Visible = True
Set MyXLSheet = MyXL.ActiveSheet
'Pasting cells A & B Together
Set r = MyXLSheet.Range("C1:C2")
For n = 1 To r.Rows.Count
r.Cells(n, 1) = "=CONCATENATE(RC[-1],RC[-2])"
' Opening Drawing
ThisDrawing.Application.Documents.Open (r.Cells(n, 1))
ThisDrawing.Application.ZoomAll
' Save pointer to the current drawing
Set DOC0 = ThisDrawing.Application.ActiveDocument
' Copy objects
Set objCollection(0) = Drawing
' Create a new drawing and point to its model space
Set DOC1 = Documents.Add
Set Doc1MSpace = DOC1.ModelSpace
' Copy the objects into the model space of the new drawing.
retObjects = DOC0.CopyObjects(objCollection, Doc1MSpace)
' Get the newly created object collection and apply new
' properties to the copies.
Set DrawingCopy = retObjects(0)
ThisDrawing.Application.ZoomAll
MsgBox "Drawing copied."
Set oPref = ThisDrawing.Application.Preferences.OpenSave
oPref.SaveAsType = ac2000_dwg
ThisDrawing.SaveAs (Left(ThisDrawing.Name, Len(ThisDrawing.Name) - 4) & " (V2000).dwg")
ThisDrawing.Close
Next n
End Sub
This is what I've got, but it will probably don't make any sense.
I don't understand how I should set the whole drawing to the object collection?