.DOC files could be Rich Text Format - so use a RichTextBox, rather than a normal Text Box.
Alternatively, look at embedding Word into your application:
To embed a document within your own application, it might be better to use the OLE control, rather than the SetParent API as above.VB Code:
'The document is inside a frame on the form, rather than on the form itself. Private Declare Function SetParent Lib "User32" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long Private Declare Function FindWindowEx Lib "User32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long Private oWord As Word.Application Private oDoc As Word.Document Private Sub Command1_Click() Dim oWord As Word.Application Dim oDoc As Word.Document Dim WinHandle As Long Set oWord = CreateObject("Word.Application") oWord.Documents.Open FileName:="c:\temp\Test.doc" oWord.Documents("Test.doc").Activate oWord.Visible = True Set oDoc = oWord.ActiveDocument WinHandle = FindWindowEx(0&, 0&, vbNullString, "Test.doc - Microsoft Word") SetParent WinHandle, Frame1.hWnd End Sub Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer) Set oWord = Nothing Set oDoc = Nothing End Sub
VB Code:
Private Sub Form_Load() Me.Move 0, 0, Screen.Width, Screen.Height OLE1.Move 0, 0, Me.ScaleWidth, Me.ScaleHeight Me.Visible = True OLE1.AutoActivate = vbOLEActivateManual OLE1.Class = "Word.Document.8" 'depends on what's installed on your system OLE1.CreateEmbed "C:\My Documents\test.doc" OLE1.DoVerb vbOLEUIActivate OLE1.Visible = True End Sub




Reply With Quote