BUG: OLE Control Updated Event Fired in Endless Loop

Last reviewed: April 2, 1996
Article ID: Q149034
The information in this article applies to:
  • Standard, Professional, and Enterprise Editions of Microsoft Visual Basic, 16-bit and 32-bit, for Windows, version 4.0

SYMPTOMS

Interrupting normal execution in the Updated event of an OLE control can cause the Updated event to be fired repeatedly, in an endless loop. Displaying a modal form such as a dialog box causes this problem, as well as stepping through the code in debug mode. Execution does not happen in a normal fashion in both of these cases.

WORKAROUND

Although the code cannot be run in debug mode it does run correctly as a compiled executable provided no modal forms are shown in the Updated event. To show a modal form in response to an Updated event, you can enable a timer control in the Updated event and then have the Timer's Timer event show the form. For example:

   Private Sub OLE1_Updated(Code As Integer)
      Timer1.Enabled = True
   End Sub

   Private Sub Timer1_Timer()
      Timer1.Enabled = False
      MyForm.Show vbModal
   End Sub

STATUS

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

MORE INFORMATION

Steps To Reproduce Issue

  1. Start Visual Basic 4.0. Form1 is created by default.

  2. Add a single OLE control to the form. When prompted to insert an object choose a Microsoft Excel worksheet or Microsoft Word document. The problem can occur using other objects also.

  3. Add this code to the form:

          Private Sub Form_Click()
    
              Dim i As Integer
    
              i = FreeFile
              Open "test.ole" For Binary As i
              OLE1.SaveToFile i
              Close i
          End Sub
    
    

  4. Press F5 or click Start on the Run menu to run the application. Click once on the form to save the object to a file called Test.ole.

  5. Start another instance of Visual Basic 4.0. Form1 is again created by default.

  6. Add an OLE control to Form1. Click Cancel when prompted with the Insert Object dialog.

  7. Add this code to the form:

          Option Explicit
    

          Private Sub Form_Click()
    
              Dim i As Integer
    
              Open "test.ole" For Binary As i
              OLE1.ReadFromFile i
              Close i
    
              OLE1.DoVerb vbOLEShow
          End Sub
    
          Private Sub OLE1_Updated(Code As Integer)
              Debug.Print "Updated fired: " & Code
          End Sub
    
    

  8. Press F5 or click Start on the Run menu to run the application. Click once on the form and see that the program runs fine. Now stop the application and press F8 to start the program in step mode. Click once on the form and step through the code loading the OLE object and into the Updated event. Keep stepping through the code and notice that the Updated event is fired continually.


KBCategory: kbbuglist kbprg
KBSubcategory: IAPOLE
Additional reference words: 4.00 vb4win vb4all buglist4.00



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: April 2, 1996
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.