Setparent Word to Modal Form
Hi everyone!!!
Why is Setparent not working on modal forms but works perfect with modeless forms?
Here is my code on module.
Code:
Public Sub GrabMicrosoftWord(ByVal wName As String)
Dim MicWord As Long
MicWord = FindWindow(vbNullString, wName & ".doc - Microsoft Word")
If MicWord = 0 Then
Exit Sub
Else
SetParent MicWord, Form1.hwnd
End If
End Sub
I call it like.
Code:
Form1.Show vbModal
GrabMicrosoftWord (wName)
vbmodal won't trigger SetParent. What is the workaround for this thanks?
-zynder
Re: Setparent Word to Modal Form
If you put a breakpoint on the GrabMicrosoftWord line, you will see that it does not get triggered. By showing your form modally, all lines of code that follow must wait til the modal form is either unloaded or hidden. It's not that it isn't working, the line of code is not being executed until your modal form closes.
Try swapping the 2 lines. Better?