XmlMappedRange.MergeArea Property

Definition

Gets a Range that represents the merged range containing the XmlMappedRange control.

public:
 property Microsoft::Office::Interop::Excel::Range ^ MergeArea { Microsoft::Office::Interop::Excel::Range ^ get(); };
public Microsoft.Office.Interop.Excel.Range MergeArea { get; }
member this.MergeArea : Microsoft.Office.Interop.Excel.Range
Public ReadOnly Property MergeArea As Range

Property Value

A Range that represents the merged range containing the XmlMappedRange control. If the XmlMappedRange control is not in a merged range, this property returns the XmlMappedRange control.

Examples

The following code example displays the value of the MergeArea and MergeCells properties before and after merging a range that contains an XmlMappedRange. This code example assumes that the current worksheet contains an XmlMappedRange named CustomerLastNameCell that is in one of the cells from cell B2 to B5.

private void SetMergeArea()
{
    Excel.Range range1 = this.Range["B2", "B5"];

    string beforeMergeAddress = 
        CustomerLastNameCell.MergeArea.get_Address(
        Excel.XlReferenceStyle.xlA1);

    MessageBox.Show("Before merging, the MergeArea property is '" +
        beforeMergeAddress + "' and the MergeCells property is " +
        " '" + CustomerLastNameCell.MergeCells.ToString() + "'.");

    range1.Select();
    range1.Merge(false);

    string afterMergeAddress =
        CustomerLastNameCell.MergeArea.get_Address(
       Excel.XlReferenceStyle.xlA1);

    MessageBox.Show("After merging, the MergeArea property is '" +
        afterMergeAddress + "' and the MergeCells property is " +
        " '" + CustomerLastNameCell.MergeCells.ToString() + "'.");
}
Private Sub SetMergeArea()
    Dim range1 As Excel.Range = Me.Range("B2", "B5")

    Dim beforeMergeAddress As String = _
        CustomerLastNameCell.MergeArea.Address( _
        ReferenceStyle:=Excel.XlReferenceStyle.xlA1)

    MsgBox("Before merging, the MergeArea property is '" & _
        beforeMergeAddress & "' and the MergeCells property is " & _
        " '" + CustomerLastNameCell.MergeCells.ToString() & "'.")

    range1.Select()
    range1.Merge(False)

    Dim afterMergeAddress As String = _
        CustomerLastNameCell.MergeArea.Address( _
        ReferenceStyle:=Excel.XlReferenceStyle.xlA1)

    MsgBox("After merging, the MergeArea property is '" & _
        afterMergeAddress & "' and the MergeCells property is " & _
        " '" + CustomerLastNameCell.MergeCells.ToString() & "'.")
End Sub

Remarks

The MergeArea property only works on a single-cell range.

Applies to