Since Optional function arguments are variants, the VarType() function should be used to "sub-type" these arguments for a non-variant data type. The sample code fragment below illustrates the form:
Public Sub OpenTextFile(FileName As String, _ Optional OpenWrite = False)
On Error GoTo HandleErr
'Check optional input.
If VarType(OpenWrite) <> vbBoolean Then Err.Raise 450
'More code may go here.
End Sub
Note the use of the instrinsic constant vbBoolean. For a complete list of contants refer to the online help documentation.