Тема: Помогите связать Autocad c Excel
Задаяа такая создаю чертеж в автокае потом (либо программно - лучше так, либо самомцу открываю чичтый лист эеселя)открываю ексел и хочу туда записать в нужные ячейки нужные циферкичто бы потм связывать данный черже с этим файлом и так далее.
Пробвал примеры на форумах которые выдает ошибку Can't find progect ot libery.
Option Explicit ' by Fatty 2007 ' Request reference to Microsoft Office 11.0 Object Library Dim oSset As AcadSelectionSet Sub WriteBlocks() Dim xlApp As Excel.Application Dim xlBook As Workbook'- РУГАЕТСЯ В ЭТОМ МЕСТЕ Dim wbkobjs As Workbooks Dim xlSheet As Worksheet Dim shtobjs As Worksheets Dim xlPath As String xlPath = ThisDrawing.Path & "\MyBlocks2.xls" On Error Resume Next Err.Clear Set xlApp = GetObject(, "Excel.Application") If Err <> 0 Then Err.Clear Set xlApp = CreateObject("Excel.Application") If Err <> 0 Then MsgBox "Cannot start Excel", vbExclamation End End If End If On Error GoTo Err_Control xlApp.Visible = False Set xlBook = xlApp.Workbooks.Add Set xlSheet = xlBook.Worksheets(1) Dim fcode(1) As Integer Dim fData(1) As Variant Dim dxfcode, dxfdata Dim i As Long, j As Long, k As Long Dim setName As String Dim blkRef As AcadBlockReference Dim oEnt As AcadEntity Dim oText As AcadText Dim ins As Variant Dim upt As Variant Dim dblHgt As Double Dim attVar() As AcadAttributeReference Dim objAtt As AcadAttributeReference fcode(0) = 0 fData(0) = "INSERT" fcode(1) = 66 fData(1) = 1 dxfcode = fcode dxfdata = fData setName = "$Blocks$" For i = 0 To ThisDrawing.SelectionSets.count - 1 If ThisDrawing.SelectionSets.Item(i).name = setName Then ThisDrawing.SelectionSets.Item(i).Delete Exit For End If Next i Set oSset = ThisDrawing.SelectionSets.Add(setName) oSset.SelectOnScreen dxfcode, dxfdata MsgBox oSset.count j = 1 k = 1 dblHgt = ThisDrawing.GetVariable("DIMTXT") ' change text height you need For Each oEnt In oSset Set blkRef = oEnt ins = blkRef.InsertionPoint Set oText = ThisDrawing.ModelSpace.AddText(CStr(k), ins, dblHgt) oText.color = acYellow upt = ThisDrawing.Utility.TranslateCoordinates(ins, acWorld, acUCS, False) attVar = blkRef.GetAttributes xlSheet.Cells(j, 1) = "BLOCK #" & CStr(k) xlSheet.Cells(j + 1, 1) = "BLOCK NAME:" xlSheet.Cells(j + 1, 2) = blkRef.name xlSheet.Cells(j + 2, 1) = CStr(Replace(CStr(upt(0)), ".", ",", 1, -1)) xlSheet.Cells(j + 2, 2) = CStr(Replace(CStr(upt(1)), ".", ",", 1, -1)) xlSheet.Cells(j + 2, 3) = CStr(Replace(CStr(upt(2)), ".", ",", 1, -1)) j = j + 3 For i = 0 To UBound(attVar) Set objAtt = attVar(i) xlSheet.Cells(j, 1) = objAtt.TagString xlSheet.Cells(j, 2) = objAtt.TextString j = j + 1 Next i j = j + 1 k = k + 1 Next oEnt Exit_Here: xlSheet.UsedRange.Columns.AutoFit xlBook.SaveAs xlPath, , , , False xlBook.Close xlApp.Quit Exit Sub Err_Control: If Err.Number <> 0 Then MsgBox Err.Number & " --> " & Err.Description Else MsgBox "Done" End If Set xlApp = Nothing Set xlBook = Nothing Set wbkobjs = Nothing Set xlSheet = Nothing Set shtobjs = Nothing Resume Exit_Here End Sub
Галочки в референсах на ечсуд 11,0 поставлены. в чем дело не могу понят. Подскажите что не так ..или дай просто пример а далша сам разберусь или подскажите где смотреть
Использую автокад2007, ексел 11.5612.5703.
Заранее спасибо.