After much trial and error trying to get all the functionality of word into a windows form, decided the best approach is the api calls and parenting an instance of word to a panel control. Its more or less working but getting weird redraw issues and also having to close and reopen the active document for it to show at all
Heres a brief on the code
Im wondering if I need to do something else with the instance of word - any ideas?
Heres a brief on the code
Code:
Private _wordHandle As IntPtr
Public Const GWL_STYLE = (-16)
Public Declare Function FindWindow Lib "User32.Dll" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As IntPtr
Public Declare Function SetParent Lib "User32.Dll" (ByVal hWndChild As IntPtr, ByVal hWndNewParent As IntPtr) As Long
Public Declare Function MoveWindow Lib "User32.Dll" (ByVal hwnd As IntPtr, ByVal X As Integer, ByVal Y As Integer, ByVal nWidth As Integer, ByVal nHeight As Integer, ByVal bRepaint As Integer) As Integer
Dim parentHandle As IntPtr
Dim doc As Word.Document
_wordInstance = CreateObject("Word.Application")
doc = _wordInstance.Documents.Open("c:\test\autotest.dot", False, False)
_wordHandle = FindWindow("OpusApp", _wordInstance.ActiveWindow.Caption & " - Microsoft Word")
parentHandle = uxWordContainer.Handle
SetParent(_wordHandle, parentHandle)
MoveWindow(_wordHandle, 0, 0, uxWordContainer.Width, uxWordContainer.Height, 1)
'Shouldnt need this but wont show without it
_wordInstance.Documents.Close(False)
_wordInstance.Documents.Open("c:\test\autotest.dot", False, False)
Im wondering if I need to do something else with the instance of word - any ideas?