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!

How do I open a Word or Excel file using the associated application?

Status
Not open for further replies.

SirPaladin

Programmer
Jul 9, 1999
32
0
0
US
I want to open files using the application associated with their filename extension. For instance, if I have the complete path to a .doc file, I want to open that file in Word, or whatever application is associated with the file's extension. I have not been able to find what I need to do to effectively RUN("C:\TestProject\Testnote.doc"). Anyone know how? [sig][/sig]
 
You will need to add the Word and Excel Object Libraries to your Project References.

Excel
Workbooks.Open FileName:="C:\Temp\MyFile.XLS"
Workbooks.Application.Visible = True

Word
Dim wdApp As Word.Application
wdApp.Documents.Open FileName:="C:\Temp\MyDoc.doc", ReadOnly:=True, Format:=wdOpenFormatAuto

Hope this helps.
[sig][/sig]
 
Search for ShellExecute in this forum -- slightly more flexible solution, though tclere - as always - is perfectly correct. [sig]<p>Mike<br><a href=mailto:michael.j.lacey@ntlworld.com>michael.j.lacey@ntlworld.com</a><br><a href= Cargill's Corporate Web Site</a><br>Making mistakes, so you don't have to. &lt;grin&gt;[/sig]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top