Microsoft KB Archive/299206

= Visio2002: Error Message: Compile Error: Sub or Function Not Defined =

Article ID: 299206

Article Last Modified on 10/11/2006

-

APPLIES TO


 * Microsoft Visio 2002 Standard Edition
 * Microsoft Visio 2002 Professional Edition

-



This article was previously published under Q299206





SYMPTOMS
If you attempt to use the sample code for the SetFilterCommand method from Visio Developer Reference, you may receive an error message similar to the following:

Compile error: Sub or Function not defined



CAUSE
This behavior can occur because the sample code in Visio Developer Reference for the SetFilterCommand method is incorrect. The SetFilterCommand method needs an array of command ranges and a True or False value that indicates how to filter events for each command range. The array needs to have a multiple of 3 elements. The two code samples create arrays of 4 and 10 elements.



RESOLUTION
The following code samples are correct: Dim cmdArray(1 To (1 * 3)) As Long 'Ignore the layout command cmdArray(1) = visCmdLayoutDynamic cmdArray(2) = visCmdLayoutDynamic cmdArray(3) = False NOTE: The sample in Visio Developer Reference does not dimension the array correctly.

Dim cmdArray(1 To (3 * 3)) As Long ' Pay attention to the Send To Back command cmdArray(1) = visCmdObjectSendToBack cmdArray(2) = visCmdObjectSendToBack cmdArray(3) = True 'Ignore any command IDs before the Send To Back command cmdArray(4) = visCmdFirst cmdArray(5) = visCmdObjectSendToBack - 1 cmdArray(6) = False 'Ignore any command IDs after the Send To Back command cmdArray(7) = visCmdObjectSendToBack + 1 cmdArray(8) = visCmdLast cmdArray(9) = False NOTE: The sample in Visio Developer Reference has the following errors:
 * The array is improperly dimensioned.
 * The array is called cmdArray, but several of the elements are listed as commmands.
 * The constants visCmdFirst and visCmdLast are incorrectly typed as visCmdCMDFIRST and visCmdCMDLAST.
 * Elements 4 through 6 are used twice, and elements 7 through 9 are not used.



STATUS
Microsoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article.

Additional query words: prb vb vba vbe error 35

Keywords: kbbug kberrmsg kbpending KB299206

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.