Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Shell an Office file: Get the locations of Excel.exe, Winword.exe, Pwrpoint.ext on user's pc

Posted on 2004-10-26
4
Medium Priority
?
388 Views
Last Modified: 2008-02-01
(Continuation of http://www.experts-exchange.com/Databases/MS_Access/Q_21182166.html)

Hi all

I use the following lines to open a text file using Shell, and it works fine...

sShellPath = "Notepad.exe " & Chr(34) & sDestinationPath & Chr(34)
dbl = Shell(sShellPath, vbMaximizedFocus)

This works great for Notepad, but if I try this with any other Office document (removing the "Notepad.exe"), I get a "Invalid procedure call or argument" runtime error #5.  If I put in the full path/file of Word, Excel, etc. it works fine.

So...  either is there another way to do this without getting the file locations of Word, Excel, etc., or how can I programmatically get these file locations?

I'm using Windows XP SP2/Office XP

Thanks in advance.
-Jim
0
Comment
Question by:Jim Horn
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 41

Accepted Solution

by:
shanesuebsahakarn earned 2000 total points
ID: 12412691
Don't use Shell - you can use either of these methods to launch a file in its default handler:

FollowHyperlink "C:\Temp\MyFile.txt"

or use ShellExecute instead (more flexible):
http://www.mvps.org/access/api/api0018.htm
0
 
LVL 26

Expert Comment

by:Alan Warren
ID: 12412775
I agree use the shellexecute api


Sample using ShellExecute here:
http://www26.brinkster.com/alzowze/Blob_UnPack.asp?Filename=ImportBulkFiles.zip

Alan
0
 
LVL 66

Author Comment

by:Jim Horn
ID: 12412806
Application.FollowHyperlink, learn something new every day.

Thanks.  For some reason, I was getting the error#5 when opening a text file in Notepad using ShellExecute, but do not get this error opening any other type of file.
0
 
LVL 2

Expert Comment

by:rene119
ID: 12412811
Hi Jim,

This is how I open a word document for access. I've used it in access 97 and 2000.

Dim objWD As Object

Set objWD = CreateObject("Word.Application")

objWD.Visible = True

objWD.Documents.Open "Full Path to Word Document to Open"

Set objWD = Nothing

Hope this helps

Rene
0

Featured Post

Tech or Treat!

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
Explore the ways to Unlock VBA Project Password Excel 2010 & 2013 documents. Go through the article and perform the steps carefully to remove VBA Excel .xls file.
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question