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

open a file?

Status
Not open for further replies.

peach255

Programmer
Jan 20, 2003
29
US
How can I have Excel open a file? For ex, a Word document called "test.doc"? I have the following code to open the Word application successfully, but I basically just want to open the file.
Thank you!

On Error Resume Next
Program = "WINWORD.exe"
TaskId = Shell(Program, 1)
If Err <> 0 Then
MsgBox &quot;Cannot start &quot; & Program, vbCritical, &quot;Error&quot;
End If
 
This is how i open a word help file through an excel vba program that i did....hope this helps. You can use fso objects for better decleration of my helfilename variable

Dim word_app As Word.Application 'early binds variable to word application
Dim help_doc As Word.Document 'early binds to word doc
Dim help_filename As String


'change the below destination to where there help file is going to be kept

help_filename = &quot;whatever the filename is that you want&quot;

On Error Resume Next

'used so no more than one instance of word can be created through the help button

Set word_app = GetObject(, &quot;word.application&quot;) 'searches for an open word document
If Err Then 'if not open
Set word_app = New Word.Application 'opens a word application
End If


'opens help file as readonly
word_app.Documents.Open _
FILENAME:=help_filename _
, ReadOnly:=True _
, Visible:=True

word_app.Visible = True
word_app.Activate


Set word_app = Nothing 'deallocates the object references
Set help_doc = nothing
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top