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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Opening a Word document using VB 6

Status
Not open for further replies.

rayt

Instructor
Mar 27, 2001
7
US
How do I open a Word document from a VB 6 program? Any helps will be highly appreciated.

rayt
 
Many people have suggested using the WebBrowser control and navigating to the document (using a fule URL).

Haven't tried it myself - may be read-only that way.

You could also Shell an instance of Word itself too.

This all assumes the user has Word installed of course, though Word Viewer will work if installed as well.
 
I have been able to open Word.exe using the shell function. The problem is how to open the Word file that was listed in the common dialog box. Is there a way to pass the commonDialog.filename to the Shell funtion so the file will automatically open as a Word document.

Thanks for any helps.
 
I found an earlier thread to open a Word document from a VB program. The following are the codes originally written by dsi. Thanks dsi for your codes. I included some codes to open the Word document from the common dialog open box.

'include the Microsoft Word Object Library in
' project references.
Dim strFile As String ' variable for the file name
clgOpen.ShowOpen ' common dialog box
strFile = clgOpen.FileName ' returned file name

'the rest are the codes written by dsi (programmer)
Dim wdApp As Word.Application

Set wdApp = New Word.Application
wdApp.Visible = True
wdApp.WindowState = wdWindowStateMaximize

wdApp.Documents.Open FileName:=strFile, ConfirmConversions:= _
False, ReadOnly:=False, AddToRecentFiles:=False, PasswordDocument:="", _
PasswordTemplate:="", Revert:=False, WritePasswordDocument:="", _
WritePasswordTemplate:="", Format:=wdOpenFormatAuto

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top