Microsoft KB Archive/937622

= Visio 2007 may close unexpectedly (crash) when you create a new page after you set the &quot;Src&quot; property programmatically =

Article ID: 937622

Article Last Modified on 6/6/2007

-

APPLIES TO


 * Microsoft Office Visio Professional 2007
 * Microsoft Office Visio Standard 2007

-



SYMPTOMS
Consider the following scenario. You embed the Microsoft Office Visio 2007 drawing control on a form, in a custom application, or in another Microsoft Office application. You set the Src property programmatically. Then, you create a new page programmatically, or you create a new page by using the user interface.

In this scenario, Visio 2007 may close unexpectedly (crash).



CAUSE
This issue occurs because of a known issue that occurs when the Src property of the Visio drawing control is set before you create the new page.



WORKAROUND
To work around this issue, add code to perform a SendMessage operation to send private message ID 2100 to the drawing window. Add the code after you set the Src property and before you add the new page.

In Microsoft Visual Basic for Applications, use the following code. ' declare win32 function Private Declare Function SendMessage Lib &quot;user32&quot; Alias &quot;SendMessageA&quot; (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long

Private Sub LoadDocument ' assign source file DrawingControl1.Src = &quot;C:\Drawing1.vsd&quot;

' send private message to Visio to start workaround SendMessage DrawingControl1.Window.WindowHandle32, 2100, 0, 0

' add page DrawingControl1.Document.Pages.Add

End Sub For more information about sample code methods for this workaround for most major languages, visit the following Microsoft Web site:

http://blogs.msdn.com/wmorein/archive/2007/01/26/visio-2007-bug-in-drawing-control.aspx

Additional query words: VISIO2007 VSO2007

Keywords: kbexpertiseinter kbtshoot kbprb KB937622

-

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

© Microsoft Corporation. All rights reserved.