Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

View Word Document in VB Form 1

Status
Not open for further replies.

mans

Programmer
Mar 18, 2000
136
0
0
AU
Hello,

Can you please let me know how can I open a Word template file using the Word object within a VB form. I do not know how to attach the document to the form, I have not been able to find any documentation in this regard. I use VB6 and MS Office 2000.

Thank You
 
Code:
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function SetParent Lib "user32" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long

Private Sub Form_Load()
Dim wordApp As Word.Application
Dim z As Word.Document
Dim iHandle As Long, iFrame As Long

Set wordApp = CreateObject("Word.Application")
Set z = Word.Documents.Open("C:\1.doc") 'hardcoded
wordApp.Visible = True
iHandle = FindWindow("OpusApp", vbNullString)
iFrame = SetParent(iHandle, Form1.hwnd)
End Sub
From:
 
Thank you very much for your response. I have a tab control that has a Word document in it, when I double click on the Word documnet to edit it, it opens up MS Word outside the form. I would like the MS Word document to appear within the tab control, not outside it, can you please tell me how I can do that.
 
I'd use an OLE control in preference to all that SetParent stuff
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top