Logo 
Search:

MS Office Forum

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds

Opening non-Office file from Excel

  Asked By: Nichole    Date: Feb 15    Category: MS Office    Views: 822
  

I need to be able to open a file of any extension from Excel VBA. So
far I have done this by creating a temporary hyperlink which is removed
after being followed. This works in most cases but I have run into
instances where some applications won't run e.g. an .mpg file will open
from Windows Explorer with the default video player but not from a
hyperlink in Excel. Any suggestions on other methods would be
appreciated.

Share: 

 

2 Answers Found

 
Answer #1    Answered By: Aberto Rossi     Answered On: Feb 15

I've used several variations of 'Shell".
You should be able to use:

WordFile = "C:\temp\SampleFile.doc"
WID = Shell("C:\Program Files\Microsoft Office\OFFICE11\WINWORD.EXE " &
WordFile, 1)

In cases where I want to Leave Word running, but open/close multiple Word files,
I've used:

WID = Shell("C:\Program Files\Microsoft Office\OFFICE11\WINWORD.EXE ", 1)
Application.Wait (Now + TimeValue("0:00:03")) 'this added to ensure Word is
started before opening  files
Set wrd = GetObject(, "Word.Application")
'set up loop
WordFile = "C\temp\SampleFile.doc"
wrd.Documents.Open WordFile
wrd.Documents.Close
'close loop
wrd.quit

In this case, you would have to determine which application is to run  based on
the file  extension.

 
Answer #2    Answered By: Nina Garcia     Answered On: Feb 15

I've used several variations of 'Shell".
You should be able to use:

WordFile = "C:\temp\SampleFile.doc"
WID = Shell("C:\Program Files\Microsoft Office\OFFICE11\WINWORD.EXE " &
WordFile, 1)

In cases where I want to Leave Word running, but open/close multiple Word files,
I've used:

WID = Shell("C:\Program Files\Microsoft Office\OFFICE11\WINWORD.EXE ", 1)
Application.Wait (Now + TimeValue("0:00:03")) 'this added to ensure Word is
started before opening  files
Set wrd = GetObject(, "Word.Application")
'set up loop
WordFile = "C\temp\SampleFile.doc"
wrd.Documents.Open WordFile
wrd.Documents.Close
'close loop
wrd.quit

In this case, you would have to determine which application is to run  based on
the file  extension.

 
Didn't find what you were looking for? Find more on Opening non-Office file from Excel Or get search suggestion and latest updates.




Tagged: