XLL+ Class Library (7.0)


Returns a copy of the first (or only) single reference in a single or multiple range reference

CXlRef GetRef( ) const;

Return Value

Returns a single range reference, by value or by reference. If the CXlOper contains a multiple reference, then the function will return the first single reference it contains.


The function will throw an exception of type CXlBadOperTypeException if the object does not contain a single or multiple reference. GetRef() should be used only if IsRef() returns TRUE, as in:

if ( xlo.IsRef() )
    cRows = xlo.GetRef().Height();

Breaking change

Under XLL+ version 5 and below, this method returned a reference to the actual CXlRef contained within the CXlOper, which could then be written to directly. In order to support Excel 2007 as well as earlier versions of Excel, this functionality has had to be changed.

The method now returns a copy of the CXlRef contained in the CXlOper; in order to change its value, you must call SetRef to apply any changes. Thus, if your existing code is:

xloRef.GetRef().MoveBy(0, 1);

You will need to change it to:

CXlRef xlr = xloRef.GetRef();
xlr.MoveBy(0, 1);

Alternatively, you can use the new short-hand function:

xloRef.MoveRefBy(0, 1);


Header: xllplus.h

See Also

CXlOper Class | CXlOper Methods | CXlOper::SetRef() | CXlOper::GetRefCount() | CXlOper::GetRefItem()