Australia’s Constitutional and Judicial System” By Stephen Gageler, Chief Justice of Australia

Taken from the speech “Australia’s Constitutional and Judicial System” By Stephen Gageler, Chief Justice of Australia

Question from Judge YAMADA Yoko of the Yokohama District Court:
In the near future, artificial intelligence might be able to provide logical judgments more cheaply and
efficiently than humans. Given that possibility, what do you believe are the irreplaceable values that human judges and human courts can offer to society, and what qualities and capabilities should judges cultivate in order to deliver that value? I would be very interested in your thoughts on the role and significance of judges in the age of AI.
Chief Justice Gageler’s answer:
I think this is the second most difficult question to be asked. And my difficulty is that I know a lot
about judging but I don’t know very much about AI, although I have really sought earnestly to understand it.
I fear that there is very little that the judge does that AI cannot do better. There is a famous description
of law by Sir Edward Coke, the great Lord Chief Justice of England who had to confront James the First
of England, who, as King, decided that he could judge disputes between his subjects as well as could his
judges. The King’s argument was that law was just reason, and that he, as King, had reason as much as any judge, and that he could do the job just as well. Lord Coke had to explain “No, Your Majesty. Law is
artificial reason, and only with deep learning and long experience can the artificial reason of the law be brought to bear on disputes
.” And His Majesty, said Lord Coke, “although very wise in human affairs, did not appreciate this artificial reason.”
Now that always struck me as a very stylized but adequate explanation of the nature of legal reasoning
as distinct from ordinary human reasoning. I think artificial intelligence is artificial reasoning on stilts. I
think that it is likely to produce more predictable, equally learned, if not more learned, and fair outcomes
than human judges. This is my true fear.
What is it that a human can bring to the process that artificial intelligence will not be able to bring to
the process either now or in two years? I don’t think there’s very much, but I think there is something that
is really more important in criminal law than in civil law. My prediction is that civil law practice will probably
be overtaken by artificial intelligence very soon. But I think in criminal law there is something about the
vulnerability, the identification, the humanness of the subject matter, or the object or the person who is to
be subjected to criminal liability. I can’t articulate it particularly well but there’s something fundamentally
important about the person who is making the decision that somebody else is to be deprived of their liberty for what they have done being a person who could equally be deprived of their liberty if they did the same thing. I think there’s something fundamentally important about a human subjecting another human to punishment.

Australia’s Constitutional and Judicial System By Stephen Gageler Chief Justice of Australia

Why I think lawyer coders should begin their coding ventures with Visual Basic for Applications


As a lawyer coder, you will want to play around with Word documents. You may explore document automation or assembly. To do this, you will need to be able to code the find, replace, and search for terms or symbols. You may wish to code macros in Word to automate tasks.
Beginning your coding journey with Visual Basic for Applications (VBA) is a wise first step, as it combines tradition with tangible, real-world impact. VBA lives inside tools you already use – Excel, Word, and Outlook -so your code immediately solves everyday problems: searching through data, generating contracts, building a contract suite, and automating repetitive tasks. That instant utility keeps motivation high and shows programming as a craft that serves precise legal and business needs.

VBA’s syntax is readable and forgiving. You learn timeless fundamentals – variables, data types, loops, conditionals, procedures, functions, and modular design – without wrestling with complex setup or package management. The Macro Recorder (built into Word) provides a unique apprenticeship: you record an action, inspect the generated code, and refine it. This “watch, mimic, improve” cycle teaches event-driven thinking and object models in a familiar setting. That’s unique because if you don’t know the basics of coding, you can create a macro. The macro then provides you with the code, from which you can learn.

Debugging in the VBA editor is beginner-friendly: you can step through code, set breakpoints, watch variables, and use the Immediate window. These habits form the backbone of disciplined development in any computer language. At the same time, the Office object models (e.g., Excel’s Range, Worksheet, Workbook) introduce you to APIs and documentation reading skills that transfer directly to modern ecosystems. You can control these through settings and avoid compiling them separately, unlike some other languages, such as Python and FORTRAN.

VBA also cultivates professional value quickly. Many organisations still rely on spreadsheets, templates, and macros; becoming the person who automates a monthly task from four hours to four minutes builds credibility and creates a portfolio of visible wins. It teaches respectful extension of established systems rather than needless reinvention -an attitude prized in both legal and software teams.

Finally, VBA is a launchpad, not a cul-de-sac. Once comfortable, you can graduate smoothly to Python, JavaScript, or C# – applying the same logic structures, testing discipline, and API fluency. In short: VBA offers low friction, immediate usefulness, and solid foundations, honouring how things have long been done while preparing you to build what comes next.

Please give it a go. Turn on the Developer tab and experiment. You don’t need to hire a programmer or pay for a fancy document automation tool. Get into it!

What is a Warren truss?

The term “Warren Truss” refers to a type of structural design, and it has been used in many aircraft, primarily as interplane struts on biplanes and for the fuselage or wings. Not to be confused with the Australian Politician Warren Errol Truss, who served as the 16th deputy prime minister of Australia and the minister for Infrastructure and Regional Development in the Abbott government and the Turnbull government.

Examples include the interplane struts on the Handley Page H.P.42 and Fiat CR.42, and for the fuselage frame of planes like the Piper J-3 Cub and Hawker Hurricane. The design is also featured in modern model aircraft construction; as follows:

-Handley Page H.P.42: An early British airliner that featured Warren truss interplane struts.


-Fiat CR.42: An Italian fighter aircraft from the World War II era that also used Warren truss bracing.


-Ansaldo SVA: A series of fast Italian reconnaissance biplanes from World War I that were built with this design.


-Piper J-3 Cub: A well-known civilian aircraft that uses a Warren truss design for its fuselage frame.


-Hawker Hurricane: A famous British fighter from WWII, which also incorporated this truss design in its fuselage construction.

Key aspects of the FEA process


Model creation: A CAD model of the fuselage truss is imported into FEA software like Ansys Workbench.
Material definition: The appropriate material properties are assigned to the truss elements (e.g., aluminum alloy, composite materials like CFRP).


Load and boundary conditions:
Loads: Simulate flight loads, such as pressure on the fuselage, and loads from other components like wings, engine, and landing gear.


Boundary conditions: Apply constraints to represent how the structure is supported, such as fixing certain edges.


Meshing: The geometry is discretized into a mesh of smaller elements (e.g., beam or shell elements) for the analysis to solve.


Solution: The FEA solver calculates the stresses, strains, and deformations throughout the structure based on the applied loads and boundary conditions.


Post-processing: Results are visualized as plots and animations to show how the truss deforms and where the highest stresses occur.

Finite Element Analysis (FEA) of an aircraft fuselage

Finite Element Analysis (FEA) of an aircraft fuselage truss is a method used to simulate and analyze the structural performance of a truss-like fuselage, which is a rigid framework of members like beams and struts.

FEA models the truss as a system of interconnected elements to calculate deformations, stresses, and strains under various load conditions, ensuring the structure meets performance requirements like strength and minimum weight.

This process is crucial for modern aircraft design optimization, helping to create lightweight yet strong structures

What is a securitisation swap?

A securitisation swap is a derivative contract that is typically used in the context of securitisation transactions to hedge or manage risks related to the underlying asset pool or the structured financing involved in the securitisation process. It allows the parties involved in the securitisation (such as the issuer, the arranger, or investors) to mitigate certain types of risks, such as interest rate risk, credit risk, or currency risk, associated with the securitised assets or liabilities.


Securitisation swaps can take various forms depending on the specific needs of the transaction, but they generally fall into two broad categories: interest rate swaps and credit default swaps. Here’s an overview of these types of swaps in the context of securitisation:

Interest Rate Swap in Securitisation
Purpose: One of the most common types of swaps used in securitisation transactions is an interest rate swap. This is typically used to hedge against the risk that the interest rate exposure on the securitised assets (e.g., loans or mortgages) may differ from the financing costs or liabilities.

    How it Works: In an interest rate swap:
    The asset pool in the securitisation may consist of fixed-rate loans or floating-rate loans.


    The issuer or sponsor of the securitisation may enter into an interest rate swap agreement to convert the fixed interest payments on the asset pool into floating-rate payments (or vice versa) to better match the interest payments on the issued securities.


    For example, if the securitised assets are mostly fixed-rate loans, but the issuance of securities is based on floating rates (e.g., LIBOR), the issuer may enter into a swap agreement to receive fixed payments and pay floating payments, aligning the cash flows between the asset pool and the securities.


    Goal: The goal is to manage the mismatch between the interest rate profile of the assets and the financing costs or to protect against fluctuations in interest rates that could negatively impact the transaction.

    What is a Warehouse securitization ?

    Warehouse securitization refers to a financial process in which a lender or financial institution (typically a bank or a non-bank lender) aggregates and finances loans or assets in a warehouse (a pool of loans or receivables). These loans or assets are held in a “warehouse” and are later “securitized,” meaning they are repackaged into securities (such as bonds) that are sold to investors. This process is commonly used in asset-backed securities (ABS) and mortgage-backed securities (MBS).

    Steps Involved in Warehouse Securitization:


    Origination of Assets: The process begins when a financial institution originates or acquires a pool of loans or receivables (e.g., mortgages, auto loans, or credit card debt). These loans are placed into a “warehouse” or a special-purpose vehicle (SPV).

    Financing the Warehouse: The institution often uses short-term financing to hold these loans in the warehouse. This short-term financing is typically obtained through a warehouse line of credit from a lender or other financial institution.
    A warehouse line of credit
    A warehouse line of credit is a type of short-term financing used by financial institutions, lenders, or companies to fund the acquisition or holding of assets, typically loans or receivables, before they are sold or securitized. It is commonly used in industries like mortgage lending, asset-backed securities, and other forms of financial lending where assets need to be stored temporarily before they are sold or packaged for longer-term financing.

    Key Features of a Warehouse Line of Credit:
    Short-Term Nature: The warehouse line of credit is usually intended for short-term borrowing, often ranging from a few months to a year. It provides immediate access to liquidity to purchase or hold assets before they are sold or securitized.

    Revolving Credit: A warehouse line of credit is often structured as a revolving credit facility. This means that once a loan or asset is sold or securitized, the borrower can repay the borrowed funds and then reuse the available credit for additional assets. This revolving nature allows for flexibility in financing.

    Collateralized: The credit provided under a warehouse line of credit is typically secured by the assets purchased or held by the borrower. For example, in a mortgage warehouse line of credit, the warehouse lender may use the mortgages that the borrower holds as collateral.

    Used by Lenders: The warehouse line of credit is particularly common in industries like mortgage origination or asset-backed securities (ABS). Mortgage lenders, for example, use warehouse lines of credit to fund the mortgages they originate until they can sell these loans to investors or in the secondary market, thus repaying the line of credit.

    Securitization: A common use of warehouse lines of credit is to finance the acquisition of assets that will eventually be securitized (e.g., mortgages, auto loans, credit card receivables). The borrowed funds are used to buy and hold the assets until they can be packaged and sold as securities.

    Cost: The interest rates on warehouse lines of credit are typically higher than traditional loans, reflecting the short-term and higher-risk nature of the borrowing. The interest rate is often based on a benchmark rate plus a spread, depending on the terms of the agreement.

    How It Works:
    Step 1: A financial institution (e.g., a mortgage lender or auto loan originator) sets up a warehouse line of credit with a financial institution (e.g., a bank or another lender).

    Step 2: The borrower (lender) uses the line of credit to fund the acquisition of loans, mortgages, or receivables. These assets are typically held by the borrower until they can be sold or securitized.

    Step 3: Once the loans or assets are sold or securitized, the borrower repays the borrowed funds (principal and interest) to the lender, freeing up the credit line for future use.

    Step 4: The borrower can continue to draw on the warehouse line of credit to fund new assets, creating a revolving cycle of borrowing and repayment.

    Example:
    A mortgage lender might use a warehouse line of credit to finance the mortgages it originates. The lender borrows money from the warehouse lender to fund the mortgage loans. The lender then sells those mortgages to investors or a larger financial institution (such as a government agency or bank). Once the sale is made, the lender repays the warehouse line of credit. This cycle allows the mortgage lender to continue originating new loans without having to use its own capital.
    Advantages of a Warehouse Line of Credit:
    Liquidity: It provides immediate access to funds, allowing the borrower to acquire assets and continue operations without waiting for the sale of those assets.
    Flexibility: As a revolving credit line, it can be used multiple times to acquire additional assets.
    Short-Term Solution: It serves as a temporary financing solution, allowing for the acquisition and holding of assets before they are liquidated or securitized.
    Risks:
    Interest Costs: Since it is short-term and often secured by the assets themselves, the warehouse line of credit can be more expensive than traditional loans.
    Credit Risk: If the borrower is unable to sell or securitize the assets, they may face difficulty repaying the borrowed funds, leading to potential financial stress or even default.
    Overleveraging: If the borrower draws heavily on the warehouse line of credit without having a clear plan to sell or securitize the assets, they risk overleveraging themselves.
    In summary, a warehouse line of credit is a vital financial tool used to bridge the gap between acquiring assets and realizing liquidity through asset sales or securitization. It is commonly used in sectors like mortgage lending and securitization and provides short-term financing against the assets that are being held.

    What is securitisation?

    Securitisation is one of the most powerful and transformative financial instruments in modern markets, but it remains a complex and often misunderstood process. At its core, securitisation allows for the conversion of illiquid assets—such as loans, mortgages, or receivables—into tradable securities that can be bought, sold, and invested in by a broad range of market participants. This process has revolutionised the way institutions manage risk, allocate capital, and raise funds, while simultaneously creating new investment opportunities.


    Whether you are a financial professional, a legal expert, a student of finance, or someone simply interested in understanding the inner workings of global markets, this blogis your comprehensive guide to the world of securitisation. In these blogs, we explore the principles, structures, legal frameworks, and economic impacts of securitisation in detail, providing you with the knowledge necessary to navigate this often intricate and sometimes opaque field.


    Securitisation is not just a financial technique; it’s a concept that lies at the intersection of finance, law, economics, and risk management. Understanding it fully requires both a solid grasp of the financial markets and a familiarity with the legal structures that support these transactions. In this book, we bridge the gap between theory and practice, offering an accessible introduction to the subject while also delving into the nuances of the securitisation process.


    From the basic principles and types of securitisation to the detailed mechanics of asset-backed securities (ABS), collateralised debt obligations (CDOs), and mortgage-backed securities (MBS), this blog provides an in-depth look at how securitisation works. We explore how different types of securitisations are structured, the role of rating agencies, investors, and servicers, and the regulatory environment that governs these transactions.


    Moreover, we address the risks and benefits associated with securitisation, highlighting both its potential to enhance liquidity and create new funding channels, as well as the challenges and controversies that have arisen—particularly in the wake of the 2008 financial crisis. By examining real-world examples and case studies, this book provides a practical perspective on how securitisation functions in today’s global financial system.


    In addition to the mechanics of securitisation itself, we also focus on the critical role of law and regulation in shaping securitisation transactions. The legal frameworks governing securitisation, from the structuring of special purpose vehicles (SPVs) to the complexities of credit enhancements, are explored in detail. Whether you’re involved in drafting agreements, negotiating terms, or ensuring compliance, understanding these legal structures is key to mastering the subject.

    Securitisation is a dynamic and evolving area of finance, and understanding it is crucial to anyone working in or studying the financial markets. We invite you to explore these blogs as a comprehensive resource that will not only enhance your knowledge but also empower you to engage confidently in the world of securitisation.

    What are the differences between a warehouse deal and a term deal


    The primary difference between a warehouse deal and a term deal lies in the structure of the financing, the timing, and the specific nature of the agreements involved. These types of deals are often used in the context of financing transactions such as loans, mortgages, or other asset-backed securities, but they function differently in terms of the duration and structure of the credit.

    The key differences between a warehouse deal and a term deal:

    1. Purpose and Use
      Warehouse Deal:

      ]A warehouse deal is typically a short-term financing arrangement used to fund the acquisition or holding of assets (such as loans, receivables, or mortgages) before they are sold, securitized, or otherwise liquidated. The financing provided in a warehouse deal is usually intended for temporary holding of assets until they can be moved onto the secondary market or packaged into a security.
      It is often used by lenders to finance the origination of loans or mortgages, where the lender borrows funds on a short-term basis to originate loans and then sells them to another investor or institution after a short period.
      Term Deal:
      A term deal, on the other hand, is a longer-term financing arrangement. It is typically used to fund long-term capital needs and involves a loan or credit facility that is repaid over an extended period (e.g., several years).
      In a term deal, the borrower receives a lump sum or a series of payments and repays the debt over a fixed term, typically at a set interest rate and with a defined repayment schedule.
    2. Duration
      Warehouse Deal:

      Short-Term: Warehouse lines of credit are short-term, often ranging from a few months to a year, depending on the deal. The borrower may use the credit facility repeatedly (revolving) as they acquire and sell assets.
      The goal is to finance the purchase of assets temporarily before those assets are sold or securitized.
      Term Deal:
      Long-Term: Term loans or deals typically have longer durations, often spanning several years. The repayment is done over a structured time frame (e.g., monthly, quarterly, or annually) based on the terms agreed upon at the outset of the deal.
      The borrower is expected to repay the principal and interest over time according to the agreed-upon schedule.
    3. Repayment Structure
      Warehouse Deal:

      Revolving: In a warehouse deal, the facility is usually revolving. The borrower can borrow and repay funds multiple times (like a line of credit) as they acquire and sell assets. Once assets are sold, the loan is repaid, and the borrower can access the funds again for new assets.
      The repayment is typically tied to the liquidation or sale of the assets.
      Term Deal:
      Fixed Payments: In a term deal, the borrower typically receives a lump sum of money or a series of disbursements and then repays the loan in fixed installments over the life of the loan, often with interest. The payment structure is rigid and defined from the outset.
      Repayments are usually scheduled and predictable over the life of the loan.
    4. Collateral
      Warehouse Deal:

      Secured by Assets: Warehouse financing is usually secured by the assets the borrower is holding (e.g., mortgages, loans, receivables). The collateral provides security to the lender in case the borrower defaults on the loan.
      The borrower may be required to pledge the assets they acquire as collateral for the warehouse line of credit.
      Term Deal:
      Secured or Unsecured: Term loans can be either secured (backed by collateral, such as property or equipment) or unsecured (where no specific assets are pledged as security). The specific nature of the collateral will depend on the agreement between the borrower and the lender.
      If secured, term loans often have specific collateral tied to the loan.
    5. Interest Rate
      Warehouse Deal:

      Higher Interest Rates: Warehouse lines of credit typically have higher interest rates than term loans. This is due to the short-term and higher-risk nature of the financing, as well as the flexibility of the revolving structure.
      The interest rate is often based on a short-term benchmark rate (such as LIBOR or SOFR) plus a spread.
      Term Deal:

      Lower Interest Rates: Term loans typically have lower interest rates compared to warehouse lines of credit, particularly if they are secured by collateral. The interest rate is usually fixed or based on a longer-term benchmark rate.
      Since the term deal is longer in duration and involves more stable repayment terms, the lender often offers more favorable interest rates.
    6. Liquidity and Flexibility
      Warehouse Deal:

      High Liquidity and Flexibility: Warehouse deals provide borrowers with high liquidity and flexibility, as they can borrow and repay funds repeatedly as they acquire and sell assets. The borrower can access additional funds as needed to acquire more assets.
      This revolving nature allows the borrower to maintain flexibility in managing their operations and financing.
      Term Deal:
      Lower Liquidity and Flexibility: Term loans are less flexible in comparison, as the borrower is committed to a fixed repayment schedule over a set period. There is no ability to access additional funds unless the borrower seeks refinancing or a new loan.
      The repayment obligations are fixed, which means the borrower must have the ability to meet the regular payments.
    7. Examples of Use
      Warehouse Deal:

      Commonly used by mortgage lenders, auto loan originators, and asset-backed securities (ABS) issuers who need short-term funding to purchase loans or receivables, with the intent to sell those assets in the secondary market or securitize them into securities.
      Term Deal:
      Commonly used for long-term financing needs such as business loans, real estate loans, or corporate financing, where the borrower requires capital for a longer period and repays the debt in structured installments over time.

      Summary
      In summary, warehouse deals are short-term, revolving credit facilities used to fund the acquisition or holding of assets until they can be sold or securitized. They are more flexible but carry higher interest rates due to their short-term nature. Term deals, on the other hand, are longer-term loans with fixed repayment schedules and typically lower interest rates. They are used for capital-intensive financing needs and often involve predictable repayments over a set period.

    VBA macro for extracting defined terms

    ‘Document assembly’ is the process by which an operator creates an entire document from a variety of component parts and then personalizes that document to meet the needs of the intended recipient.
    Included within the scope of the term ‘document assembly’ are how source clauses are:

    · created
    · neutered, and
    · assembled.

    One of the first steps in automatically assembling legal documents is identifying terms in square brackets. This is the way that some automated document assembly systems work like Pathagoras. To create a legal document for automation and assembly begins with surrounding key terms such as party names and so on with square brackets eg [William Higgs] or [Higgs Limited]. You get the idea. The idea is that the square bracketed terms will often be repeated throughout a legal document, so it is efficient to define them.

    The [Initial Unitholders] have paid the [Initial Sum] to the [Trustee] to establish a trust on the terms of the[Trust Deed].
    The terms  Initial Unitholders, Initial Sum, Trustee and Trust Deed are all obviously variables and they would be repeated throughout a contract. A 'variable' is a place holder for personal data. You should strategically place variables within your source clauses where you want that data to appear. Consequently, those variables will also appear in the first draft of any newly assembled document.
    
    At some stage in the assembly we will need to prompt the user to enter those terms.
    So lets start by producing a Word Macro that searches for terms in [ ] and produce them in a new Word Document. Once we have the Terms we can then prompt our assembly program to complete the legal contract with those specific terms. This is called an Interview. An Interview is a series of questions asked at the beginning of the final assembly process regarding what you want included/discarded in the final legal document. It consists of questions that are presented in a menu format.
    The interview is asked in a single window, with multiple questions being asked. More about the Interview in later blogs.
    
    Here is some code you can enter into a macro in Microsoft Word. Obviously make sure your Word Document has some [ ] terms in it.
    
    Option Explicit
    
    ' ===========
    ' ENTRY POINT
    ' ===========
    Sub ExtractBracketedText_ToTable()
        Dim doc As Document: Set doc = ActiveDocument
        Dim bodyRng As Range: Set bodyRng = doc.StoryRanges(wdMainTextStory) ' main text only
    
        ' Regex to capture [ ... ] (non-nested), allowing across line breaks
        Dim rx As Object: Set rx = CreateObject("VBScript.RegExp")
        rx.Global = True
        rx.IgnoreCase = False
        rx.MultiLine = True
        ' Group 1 captures the inner text (without the brackets)
        rx.Pattern = "\[([\s\S]*?)\]"
    
        If Not rx.Test(bodyRng.Text) Then
            MsgBox "No bracketed text found in the main story.", vbInformation
            Exit Sub
        End If
    
        Dim matches As Object, m As Object
        Set matches = rx.Execute(bodyRng.Text)
    
        ' Prepare a simple record type via arrays
        Dim n As Long: n = matches.Count
        Dim arrText() As String, arrPage() As Long, arrCtx() As String, arrStart() As Long, arrLen() As Long
        ReDim arrText(1 To n)
        ReDim arrPage(1 To n)
        ReDim arrCtx(1 To n)
        ReDim arrStart(1 To n)
        ReDim arrLen(1 To n)
    
        Dim i As Long, startInDoc As Long, lengthInDoc As Long
        For i = 1 To n
            Set m = matches(i - 1)
            ' Map back to document coordinates
            startInDoc = bodyRng.Start + m.FirstIndex
            lengthInDoc = m.Length
    
            arrStart(i) = startInDoc
            arrLen(i) = lengthInDoc
            arrText(i) = CleanOneLine(m.SubMatches(0)) ' inner text only
    
            ' Page number (guard errors just in case)
            Dim hitRng As Range
            Set hitRng = doc.Range(startInDoc, startInDoc + lengthInDoc)
            On Error Resume Next
            arrPage(i) = hitRng.Information(wdActiveEndAdjustedPageNumber)
            If Err.Number <> 0 Then
                Err.Clear: arrPage(i) = 0
            End If
            On Error GoTo 0
    
            ' Context snippet around the entire [ ... ] region
            arrCtx(i) = GetContextSnippet(doc, startInDoc, lengthInDoc, 45)
        Next i
    
        RenderResultsTable arrText, arrPage, arrCtx
        MsgBox "Bracketed-text report created.", vbInformation
    End Sub
    
    ' =================
    ' RENDER TO NEW DOC
    ' =================
    Private Sub RenderResultsTable(ByRef arrText() As String, ByRef arrPage() As Long, ByRef arrCtx() As String)
        Dim outDoc As Document: Set outDoc = Documents.Add
        outDoc.Activate
    
        Selection.Style = wdStyleHeading1
        Selection.TypeText "Bracketed Text Report"
        Selection.TypeParagraph
        Selection.Style = wdStyleNormal
        Selection.TypeText "Generated: " & Format(Now, "yyyy-mm-dd hh:nn")
        Selection.TypeParagraph: Selection.TypeParagraph
    
        Dim n As Long: n = UBound(arrText) - LBound(arrText) + 1
        If n <= 0 Then
            Selection.TypeText "No results."
            Exit Sub
        End If
    
        Dim tbl As Table
        Set tbl = outDoc.Tables.Add(Selection.Range, n + 1, 4)
        With tbl
            .Style = "Table Grid"
            .Cell(1, 1).Range.Text = "#"
            .Cell(1, 2).Range.Text = "Extracted Text"
            .Cell(1, 3).Range.Text = "Page"
            .Cell(1, 4).Range.Text = "Context"
            .Rows(1).Range.Bold = True
        End With
    
        Dim i As Long, row As Long
        row = 2
        For i = LBound(arrText) To UBound(arrText)
            tbl.Cell(row, 1).Range.Text = CStr(i - LBound(arrText) + 1)
            tbl.Cell(row, 2).Range.Text = arrText(i)
            If arrPage(i) > 0 Then
                tbl.Cell(row, 3).Range.Text = CStr(arrPage(i))
            Else
                tbl.Cell(row, 3).Range.Text = "-"
            End If
            tbl.Cell(row, 4).Range.Text = arrCtx(i)
            row = row + 1
        Next i
    
        ' Nice column widths (percent)
        tbl.Columns(1).PreferredWidthType = wdPreferredWidthPercent: tbl.Columns(1).PreferredWidth = 6
        tbl.Columns(2).PreferredWidthType = wdPreferredWidthPercent: tbl.Columns(2).PreferredWidth = 39
        tbl.Columns(3).PreferredWidthType = wdPreferredWidthPercent: tbl.Columns(3).PreferredWidth = 8
        tbl.Columns(4).PreferredWidthType = wdPreferredWidthPercent: tbl.Columns(4).PreferredWidth = 47
    End Sub
    
    ' ========================
    ' CONTEXT & SMALL HELPERS
    ' ========================
    Private Function GetContextSnippet(doc As Document, ByVal startInDoc As Long, ByVal lengthInDoc As Long, ByVal wing As Long) As String
        Dim L As Long, R As Long
        L = MaxLng(0, startInDoc - wing)
        R = MinLng(doc.Content.End, startInDoc + lengthInDoc + wing)
    
        Dim leftR As Range, rightR As Range, hitR As Range
        Set hitR = doc.Range(startInDoc, startInDoc + lengthInDoc)
        Set leftR = doc.Range(L, startInDoc)
        Set rightR = doc.Range(startInDoc + lengthInDoc, R)
    
        GetContextSnippet = "…" & CleanOneLine(leftR.Text) & "[" & CleanOneLine(hitR.Text) & "]" & CleanOneLine(rightR.Text) & "…"
    End Function
    
    Private Function CleanOneLine(ByVal s As String) As String
        s = Replace$(s, vbCr, " ")
        s = Replace$(s, vbLf, " ")
        s = Replace$(s, Chr$(160), " ")
        Do While InStr(s, "  ") > 0
            s = Replace$(s, "  ", " ")
        Loop
        CleanOneLine = Trim$(s)
    End Function
    
    Private Function MinLng(a As Long, b As Long) As Long
        If a < b Then MinLng = a Else MinLng = b
    End Function
    
    Private Function MaxLng(a As Long, b As Long) As Long
        If a > b Then MaxLng = a Else MaxLng = b
    End Function
    

    Good luck