Ich habe mir einen kleinen Excel Import für Punkte mit Attributen
geschrieben. Hier die Kernpunkte für den Import
Excel initialisieren
...
On Error GoTo Excel_fehler
Set excel_app = GetObject(, "excel.application")
Set excel_wb = excel_app.ActiveWorkbook
Set excel_ws = excel_wb.ActiveSheet
Set excel_range = excel_app.Selection
If excel_range.Areas.Count <> 1 Then
MsgBox "Es darf nur eine Region markiert sein!", vbCritical
GoTo Excel_fehler
End If
MaxReihe = excel_ws.UsedRange.Rows.Count
....
Werte aus Excel
...
str_Wert = excel_ws.Cells(i, com_Y.ListIndex + 1)
y = d_wert(str_Wert)
str_Wert = excel_ws.Cells(i, com_X.ListIndex + 1)
x = d_wert(str_Wert)
....
Auschnitt Blockeinfügen mit Attributten
...
On Error GoTo Fehler_Insert_block
'On Error GoTo 0
Select Case acad_TYP
Case 14
Set Blockobj = obj_ACAD_app.ActiveDocument.ModelSpace.InsertBlock(InsPkt, Block, Skal_Y, Skal_X, Richtung)
Case 15, 16, 17
Set Blockobj = obj_ACAD_app.ActiveDocument.ModelSpace.InsertBlock(InsPkt, Block, Skal_Y, Skal_X, 1, Richtung)
Case Else
MsgBox "ACAD TYP ist nicht bekannt !", vbCritical
Exit Function
End Select
' Wenn Attribut verlangt
If attr = True Or AttrHoehe = True Or AttrVA = True Then
On Error GoTo 0
' Hat der eingefügte Block Attribute
If Blockobj.HasAttributes Then
attributes = Blockobj.GetAttributes
For A = LBound(attributes) To UBound(attributes)
Set attribut = attributes(A)
If UCase(attribut.TagString) = UCase("VA") And AttrVA = True Then
attribut.TextString = VA
End If
If UCase(attribut.TagString) = UCase("PNR") And attr = True Then
attribut.TextString = pnr
End If
If UCase(attribut.TagString) = UCase("HOEHE") And AttrHoehe = True Then
attribut.TextString = ZHöhe
End If
Next A
End If
End If
....
Jetzt sollte es mit Excel klappen
Eine Antwort auf diesen Beitrag verfassen (mit Zitat/Zitat des Beitrags) IP