none
Application.Run Method bug: Fix or workaround or by design? RRS feed

  • Question

  • I have encountered what seems to be a bug in many but not all Office programs' (I have duplicated this bug in Access 2007, Access 2010, Word 2010 and Project 2007) Application.Run method, where such a method exists (Outlook does not have this method).

    To duplicate, try executing RunMe, below:

    Public Sub RunMe()
        Test 1, 1
        Test , 1
        Test 1
        Test
        Debug.Print
        Application.Run "Test", 1, 1
        Application.Run "Test", , 1
        Application.Run "Test", 1
        Application.Run "Test"
    End Sub
    Public Sub Test(Optional A As Variant, Optional B As Variant)
        Debug.Print IsMissing(A), IsMissing(B)
    End Sub 

    The expected and Excel/Powerpoint actual debug output is:

    False         False
    True          False
    False         True
    True          True

    False         False
    True          False
    False         True
    True          True

    However, the actual output from Access, Word and Project is (with the anomalous output emphasised):

    False         False
    True          False
    False         True
    True          True

    False         False
    True          True
    False         True
    True          True

    It would appear that the Access, Project & Word Application.Run method is discarding any parameters supplied after it encounters a missing parameter in its parameter list.

    This has serious implications in that it is not possible to correctly execute a procedure using Access', Project's or Word's Application.Run method with multiple optional parameters where there is a non-supplied optional parameter followed by supplied optional parameter(s).

    I believe that this is a bug in the Application.Run method, especially since it runs as expected in Excel and Powerpoint.

    Does anyone know of any of the following:

    • A workaround that doesn't involve re-writing the target procedure(s), yet still preserves the IsMissing status of variant parameters prior to subsequent non Missing Variant parameters,
    • A service pack/hotfix for Office 2010 (and previous versions) that addresses this issue,
    • A statement from an MS Office/Access/Project/Word developer that this behavior is by design (and is intentionally different in different Office applications)?


    • Edited by AMWild Wednesday, October 19, 2011 4:54 AM
    Wednesday, October 19, 2011 4:51 AM

Answers

All replies