Question : DOM algorithm question

I need to work out an algorithm that takes a physical screen of box coordinates, widths, and heights, all DIVs, and works out an object hierarchy based on the 'contains' relationship.

The kind of query I need to do is, given a match on a certain piece of text in the document, I need to ask the question: what DIV contains it? what DIV contains that DIV? etc. All based on absolute coordinates.

I wondered if there were a standard algorithm for constructing such a hierarchy from such a flat structure of absolute coordinates and sizes.

Answer : DOM algorithm question

Try this
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
Sub Main()
SetupToPrint "ALL Sales"
SetupToPrint "New Sales"
SetupToPrint "Old Sales"
End Sub

Private Sub SetupToPrint(sh As String)
    
    Sheets(sh).Activate
    Call SetPrintAreaToPivotTable
    Call SetPageBreakToXNumberOfRows

End Sub

Private Sub SetPrintAreaToPivotTable()

    With ActiveSheet
        lPTcells = .PivotTables("PivotTable1").DataBodyRange.Cells.Count
        Set rngTopLeft = .PivotTables("PivotTable1").RowRange.Cells(1)
        Set rngBotRight = .PivotTables("PivotTable1").DataBodyRange.Cells(lPTcells)
        strPTAddress = rngTopLeft.Address & ":" & rngBotRight.Address 'strPT address don't exist!
        .PageSetup.PrintArea = strAddress
    End With

End Sub

Private Sub SetPageBreakToXNumberOfRows()

    Dim Lastrow As Long
        Dim Row_Index As Long
        Dim RW As Long
    
        'How many rows do you want between each page break
        RW = 48
        
        With ActiveSheet
            'Remove all PageBreaks
            .ResetAllPageBreaks
            
            'Search for the last row with data in Column D
            Lastrow = .Cells(Rows.Count, "D").End(xlUp).Row
            
            For Row_Index = RW + 2 To Lastrow Step RW
                .HPageBreaks.Add Before:=.Cells(Row_Index, 1)
            Next
    End With

End Sub
Random Solutions  
 
programming4us programming4us