Vba Entre Autocad Et Excel: Comptage Des Blocks
Vba Entre Autocad Et Excel: Comptage Des Blocks
1
Plan :
Introduction :
Projet VBA :
Application :
Conclusion :
2
Introduction :
AutoCAD
VBA
Blocks
Excel
3
Projet VBA :
Déclaration des variables :
4
Projet VBA :
Lancer Excel et dessin du Tableau :
Set Excel = CreateObject("Excel.Application")
Set ExcelWorkbook = Excel.Workbooks.Add
Set ExcelSheet = Excel.ActiveSheet
ExcelSheet.Cells(1, 4) = "N°"
ExcelSheet.Cells(1, 5) = "Désignation"
ExcelSheet.Cells(1, 6) = "Unité"
ExcelSheet.Cells(1, 7) = "Qté"
For x = 4 To 7
ExcelSheet.Cells(1, x).Borders.Value = 1
ExcelSheet.Cells(1, x).Interior.color = RGB(255, 102, 0)
Next x
y=2
ExcelSheet.Cells(2, 5).ColumnWidth = 28
5
Projet VBA :
Comptage des blocks :
With elem
ElseIf ExcelSheet.Cells(RowNum, 5) = elem.Name Then
If TypeOf elem Is AcadBlockReference Then
ExcelSheet.Cells(RowNum, 7).Value = ExcelSheet.Cells(RowNum, 7).Value + 1
Exit For
For RowNum = 2 To y
End If
If ExcelSheet.Cells(RowNum, 5) = "" Then
Next RowNum
ExcelSheet.Cells(RowNum, 5) = elem.Name
End If
ExcelSheet.Cells(RowNum, 6) = "U"
End With
ExcelSheet.Cells(RowNum, 7).Value = 1
Next elem
y=y+1
6
Projet VBA :
Côté esthétique :
For RowNum = 2 To y – 1
Next RowNum
7
Projet VBA :
Enregistrer le travail :
8
Application :
9
Conclusion