14.07.2018, 12:52
Hallo Andreas,
ich habe die Funktion auch nicht gefunden.
Falls auch kein anderes Forenmitglied die Funktion findet, kannst Du es mit einem Makro versuchen:
![[Bild: habstandj0omp.gif]](http://www.abload.de/img/habstandj0omp.gif)
Gruß
Koter
abru schrieb:...Finde ich die Funktion nicht, gibt es das nicht, oder bin ich durch mein Satzprogramm Calamus nur einfach viel zu verwöhnt?
ich habe die Funktion auch nicht gefunden.
Falls auch kein anderes Forenmitglied die Funktion findet, kannst Du es mit einem Makro versuchen:
![[Bild: habstandj0omp.gif]](http://www.abload.de/img/habstandj0omp.gif)
Code:
Sub HorizontalerAbstand()
Dim PosStID()
If ActiveSelectionRange.Shapes.Count < 2 Then Exit Sub
ActiveDocument.Unit = cdrMillimeter
AbstandS = InputBox("Abstand in Millimeter", "Abstand", "1")
If AbstandS = "" Then Exit Sub
Abstand = Val(AbstandS)
Dim s1 As Shape, s2 As Shape
i = ActiveSelectionRange.Shapes.Count
ReDim PosStID(0 To i - 1, 0 To 1)
i = 0
For Each s In ActiveSelectionRange.Shapes
PosStID(i, 0) = s.PositionX
PosStID(i, 1) = s.StaticID
i = i + 1
Next
Call QuickSortMultiDim(PosStID)
ActiveDocument.BeginCommandGroup "Abstand einstellen"
For i = 1 To UBound(PosStID)
Set s1 = ActivePage.FindShape(StaticID:=PosStID(i - 1, 1))
Set s2 = ActivePage.FindShape(StaticID:=PosStID(i, 1))
s2.LeftX = s1.RightX + Abstand
Next i
ActiveDocument.EndCommandGroup
End Sub
'Quelle: Dieter Otter
'https://www.vbarchiv.net/tipps/tipp_1881-2-dimensionales-array-nach-beliebiger-spalte-sortieren.html
Public Sub QuickSortMultiDim(vSort As Variant, _
Optional ByVal index As Integer = 1, _
Optional ByVal lngStart As Variant, _
Optional ByVal lngEnd As Variant)
' Wird die Bereichsgrenze nicht angegeben,
' so wird das gesamte Array sortiert
If IsMissing(lngStart) Then lngStart = LBound(vSort)
If IsMissing(lngEnd) Then lngEnd = UBound(vSort)
Dim i As Long
Dim j As Long
Dim h As Variant
Dim x As Variant
Dim u As Long
Dim lb_dim As Integer
Dim ub_dim As Integer
' Anzahl Elemente pro Datenzeile
lb_dim = LBound(vSort, 2)
ub_dim = UBound(vSort, 2)
i = lngStart: j = lngEnd
x = vSort((lngStart + lngEnd) / 2, index - 1)
' Array aufteilen
Do
While (vSort(i, index - 1) < x): i = i + 1: Wend
While (vSort(j, index - 1) > x): j = j - 1: Wend
If (i <= j) Then
' Wertepaare miteinander tauschen
For u = lb_dim To ub_dim
h = vSort(i, u)
vSort(i, u) = vSort(j, u)
vSort(j, u) = h
Next u
i = i + 1: j = j - 1
End If
Loop Until (i > j)
' Rekursion (Funktion ruft sich selbst auf)
If (lngStart < j) Then QuickSortMultiDim vSort, index, lngStart, j
If (i < lngEnd) Then QuickSortMultiDim vSort, index, i, lngEnd
End Sub
Gruß
Koter