BUG: Invalid Code Generated Implementing Outlook.Mailitem

Last reviewed: September 9, 1997
Article ID: Q173571
The information in this article applies to:
  • Microsoft Visual Basic Control Creation, Learning, Professional, and Enterprise Editions for Windows, version 5.0

SYMPTOMS

The following code (created by Visual Basic using the OUTLOOK.MAILITEM object) is displayed in the color red by the Visual Basic IDE, indicating an error in the code:

   Private Sub MailItem_SaveAs(ByVal Path As String,_
         Optional ByVal Type As Variant)

CAUSE

The code generated uses "Type" in the second argument. "Type" is a reserved word in Visual Basic.

RESOLUTION

Rename the second argument from "Type" to something that is not a reserved word in this declaration:

   Private Sub MailItem_SaveAs(ByVal Path As String,_
        Optional ByVal Type As Variant)

Replace "Type" with "Arg2" as follows:

   Private Sub MailItem_SaveAs(ByVal Path As String,_
        Optional ByVal Arg2 As Variant)

STATUS

Microsoft has confirmed this to be a problem in the Microsoft products listed at the beginning of this article. We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.

MORE INFORMATION

Steps to Reproduce Problem

  1. Start Visual Basic or, if Visual Basic is already running, choose New Project.

  2. Select Project from the menu, and then select the References item. Choose the Microsoft Outlook 8.0 object module.

  3. Add a class module named Class1, and then add the following code:

          IMPLEMENTS OUTLOOK.MAILITEM
    

  4. Select "MailItem" from the Object drop-down box, and then select "SaveAs" from Procedures/Events drop-down box. The following code gets inserted in the code window:

          Private Sub MailItem_SaveAs(ByVal Path As String,_
    
            Optional ByVal Type As Variant)
       
          End Sub
    
    

  5. Note that the second argument is "Type," which is a reserved word in Visual Basic.

  6. Save the project as Project1.

  7. Close the project.

  8. Open Project1 and view your code in Class and note that the code looks like the following in the editor:

          'This line is in red >>>   Private Sub MailItem_SaveAs(ByVal Path As
          String, Optional ByVal Type As Variant)
          
          'This line is in black>>>   End Sub
    
    
The line in red means there is an error in this line of code, specifically on the name "Type."
Keywords          : vb5all
Version           : WINDOWS:5.0
Platform          : WINDOWS
Hardware          : x86
Issue type        : kbbug


================================================================================


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: September 9, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.