回复 10楼 lianyicq
非常感谢~13925919930@
Private Sub Form_Load() Me.Show 'Set EXAPP = CreateObject("excel.application") 'Set WB = EXAPP.Workbooks.Open("c:\test.xlsx") 'Set sht = WB.Worksheets("Sheet1") Set AApp = CreateObject("Autocad.Application") Set ADWG = AApp.Documents.Open("c:\drawing1.dwg") 'Range("h7", "m9").Select 'Range("h7", "m9").Copy For i = 0 To AApp.ActiveDocument.ModelSpace.Count - 1 'If AApp.ActiveDocument.ModelSpace(i).Lineweight = 106 Then ' parameter = AApp.ActiveDocument.ModelSpace(i).Coordinates ' Exit For 'End If If AApp.ActiveDocument.ModelSpace(i).EntityName = "AcDbOle2Frame" Then AApp.ActiveDocument.ModelSpace(i).LockAspectRatio = False AApp.ActiveDocument.ModelSpace(i).Width = 500 AApp.ActiveDocument.ModelSpace(i).Height = 300 NewPosition(0) = 25 NewPosition(1) = 50 NewPosition(2) = 0 Call AApp.ActiveDocument.ModelSpace(i).Move(AApp.ActiveDocument.ModelSpace(i).InsertionPoint, NewPosition) 'insertionpoint is the coordinates of ole'lower-left Form1.Print "Finish." Exit For End If Next 'CoordString = parameter(0) & "," & parameter(1) 'ADWG.SendCommand "_pasteclip" & vbCr & CoordString & vbCr 'ADWG.Save Form1.Caption = "OK" End Sub我用以上代码测试过,没有问题。我用的是ACAD2013。你可以在遍历的时候,把每次得到的实体名称显示出来,找出OLE对象的名称很容易。我就是这样找才知道OLE对象名称是AcDbOle2Frame.