[Dba-office] Direct replacement for Nz in Word/Excel

Gustav Brock gustav at cactus.dk
Thu Dec 10 07:47:24 CST 2015

Hi all

I had a need for this in Word, but couldn't find a decent solution, so here is - should you encounter the same situation:

' Replacement for Microsoft Access' function Application.Nz().
' For use in Word/Excel to eliminate the need for a reference to:
'     Microsoft Office 15.0 Access database engine Object Library.
' 2015-12-10. Gustav Brock, Cactus Data ApS, CPH.
Public Function Nz( _
    ByRef Value As Variant, _
    Optional ByRef ValueIfNull As Variant = "") _
    As Variant

    Dim ValueNz     As Variant
    If Not IsEmpty(Value) Then
        If IsNull(Value) Then
            ValueNz = ValueIfNull
            ValueNz = Value
        End If
    End If
    Nz = ValueNz
End Function


More information about the Dba-office mailing list