Guten Morgen zusammen!
Ich habe folgendes Problem.
Aus einem ListView möchte ich gerne Zeile für Zeile auslesen und in eine Tabelle schreiben.
Bei der Tabelle handelt es sich aber nicht um eine typische Exceltabelle, sondern um eine
ähnlich aufgebaute Tabelle in AutoCAD.
Das Prinzip dürfte aber ähnlich sein.
Könnte mir dabei jemand auf die Sprünge helfen wie das aussehen könnte.
Ferner möchte ich noch ListView Checkbox mit einbauen um nur bestimmte Zeilen aus dem ListView
auszulesen.
'##############################################################################
' ##########
'##---Laden und Füllen der
' UserForm------------------------------------------------------
Public Sub UserForm_Initialize()
'##--ListView Einstellungen--!!!
With ListView1
.ListItems.Clear
.ColumnHeaders.Clear
.View = lvwReport
.Sorted = True
End With
'--Spaltendefinition
With ListView1.ColumnHeaders
.Add , , "Stück", 35 'Stückzahl
.Add , , "Artikel-Nr", 60 'Artikelnummer
.Add , , "Beschreibung", 160 'Beschreibung
.Add , , "Maß X", 35 'Maß X
.Add , , "Maß Y", 35 'Maß Y
.Add , , "Maß Z", 35 'Maß Z
End With
'--Anzahl der ColumHeader
col = ListView1.ColumnHeaders.Count
row = ListView1.ListItems.Count + 2
'--Namesübergabe
li(1) = ListView1.ColumnHeaders(1)
li(2) = ListView1.ColumnHeaders(2)
li(3) = ListView1.ColumnHeaders(3)
li(4) = ListView1.ColumnHeaders(4)
li(5) = ListView1.ColumnHeaders(5)
li(6) = ListView1.ColumnHeaders(6)
'--Voreinstellungen der Schalter (CommandButton)
With cmdende
.Caption = " Beenden"
.Picture = ImageList1.ListImages(2).Picture
.PicturePosition = fmPicturePositionLeftCenter
End With
With cmdtoexcel
.Caption = " Übergabe / Tabelle"
.Picture = ImageList1.ListImages(19).Picture
.PicturePosition = fmPicturePositionLeftCenter
End With
With cmdladen
.Caption = " laden aus"
.Picture = ImageList1.ListImages(16).Picture
.PicturePosition = fmPicturePositionLeftCenter
End With
With cmddelete
.Caption = " Liste leeren"
.Picture = ImageList1.ListImages(20).Picture
.PicturePosition = fmPicturePositionLeftCenter
End With
End Sub
'##--Ereignisprozedur des Button Übergabe
' Excel---------------------------------------
Private Sub cmdtoexcel_Click()
Dim EinPkt As Variant
Me.Hide
EinPkt = ThisDrawing.Utility.GetPoint(, vbCrLf & "Bitte den Einfügepunkt" & _
"bestimmen")
Dim NewTable As AcadTable
Set NewTable = ThisDrawing.PaperSpace.AddTable(EinPkt, row, col, 1.5, 20)
NewTable.TitleSuppressed = False
NewTable.HeaderSuppressed = True
With NewTable
.RegenerateTableSuppressed = False
.SetCellTextHeight A, E, 3.5
.SetCellAlignment A, E, acMiddleCenter
.SetCellType A, E, acTextCell
.SetCellTextStyle A, E, "Tahoma"
.SetText 0, 0, "Bedarfsliste"
.SetText 1, 0, li(1)
.SetCellTextHeight 1, 0, 1.5
.SetCellTextStyle 1, 0, "Tahoma"
.SetText 1, 1, li(2)
.SetCellTextHeight 1, 1, 1.5
.SetCellTextStyle 1, 1, "Tahoma"
.SetText 1, 2, li(3)
.SetCellTextHeight 1, 2, 1.5
.SetCellTextStyle 1, 2, "Tahoma"
.SetText 1, 3, li(4)
.SetCellTextHeight 1, 3, 1.5
.SetCellTextStyle 1, 3, "Tahoma"
.SetText 1, 4, li(5)
.SetCellTextHeight 1, 4, 1.5
.SetCellTextStyle 1, 4, "Tahoma"
.SetText 1, 5, li(6)
.SetCellTextHeight 1, 5, 1.5
.SetCellTextStyle 1, 5, "Tahoma"
For i = 2 To ListView1.ListItems.Count
.SetText i, 0, LItem.SubItems(1).Text '??????
.SetCellTextHeight 1, 0, 1.5
.SetCellTextStyle 1, 0, "Tahoma"
.SetText i, 1, LItem.SubItems(2) '??????
.SetCellTextHeight 1, 1, 1.5
.SetCellTextStyle 1, 1, "Tahoma"
.SetText i, 2, LItem.SubItems(3) '??????
.SetCellTextHeight 1, 2, 1.5
.SetCellTextStyle 1, 2, "Tahoma"
.SetText i, 3, LItem.SubItems(4) '??????
.SetCellTextHeight 1, 3, 1.5
.SetCellTextStyle 1, 3, "Tahoma"
.SetText i, 4, LItem.SubItems(5) '??????
.SetCellTextHeight 1, 4, 1.5
.SetCellTextStyle 1, 4, "Tahoma"
.SetText i, 5, LItem.SubItems(6) '??????
.SetCellTextHeight 1, 5, 1.5
.SetCellTextStyle 1, 5, "Tahoma"
Next i
End With
End Sub VG
Dirk |