Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Get the complete app path to open file in VB6

Posted on 2002-03-21
14
Medium Priority
?
208 Views
Last Modified: 2012-05-04
How can I get the complete path of a app to open a file
in VB if I just know the file name and extension?

For examplo,
Supposed a file like c:\temp\test.doc
I´d like to open this file form my app,
like this:
shell ("c:\program files\msoffice\winword" c:\temp\test.doc,vbnormalfocus)

But the path c:\program files\msoffice\winword
can change from differents PC´s
or can change from differents version.
0
Comment
Question by:guiassa
[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
  • 4
  • 2
  • +4
14 Comments
 
LVL 1

Expert Comment

by:COAtheGREAT
ID: 6886013
 Dim Wrd As Object
 
  Set Wrd = CreateObject("Word.Application")
  Wrd.Documents.Open "C:\temp\doc1.doc"
0
 
LVL 28

Expert Comment

by:vinnyd79
ID: 6886064
you can use the findexecutable API

Private Declare Function FindExecutable Lib "shell32.dll" Alias "FindExecutableA" (ByVal lpFile As String, ByVal lpDirectory As String, ByVal lpResult As String) As Long
' this will return the executable that is associated with a .doc file.
Private Sub Command1_Click()
Dim strEXE As String * 255
Call FindExecutable("C:\Temp\test.doc", "", strEXE)
MsgBox strEXE
End Sub
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 6886239
shell ("start"  & "c:\temp\test.doc",vbnormalfocus)
or use shellexecute api with "open" parameter.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 6886248
Option Explicit
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long

Private Sub Form_Load()
Dim ret As Long
ret = ShellExecute(Me.hwnd, "open", "c:\test.doc", vbNullString, vbNullString, vbNormal)
End Sub
0
 
LVL 1

Expert Comment

by:prakashbitra
ID: 6886316

 Dim oWord As Object
 
 Set oWord = CreateObject("Word.Application")
 oWord.Documents.Open "C:\MyDocuments\Word1.doc"
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 6886338
Nice "answer" prakashbitra, unfortunatelly there is another one posted BEFORE.
0
 

Author Comment

by:guiassa
ID: 6888265
Vinnyd79,

Your solution is the best to my problem.
Please propose answer to get the points.

Thank you.
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 6888443
Just accetp his comment as answer.
0
 
LVL 28

Accepted Solution

by:
vinnyd79 earned 400 total points
ID: 6888729
Glad it helped.

you can use the findexecutable API

Private Declare Function FindExecutable Lib "shell32.dll" Alias "FindExecutableA" (ByVal lpFile As String,
ByVal lpDirectory As String, ByVal lpResult As String) As Long
' this will return the executable that is associated with a .doc file.
Private Sub Command1_Click()
Dim strEXE As String * 255
Call FindExecutable("C:\Temp\test.doc", "", strEXE)
MsgBox strEXE
End Sub
0
 
LVL 1

Expert Comment

by:Moondancer
ID: 7078707
Greetings.

This question has been locked with a Proposed Answer, and remains open today.  Questions in the LOCKED versus OPEN queue draw little to zero additional attention by Experts.

If the Proposed Answer did not serve your needs, please reject it and comment with an update.  If the Proposed Answer helped you, please accept it to grade and close this question.  If you need help splitting points between multiple experts, please comment here with details so we can help you.

EXPERTS ->  Please guide me here in terms of closing recommendations if the Asker does not respond in 4 days.

Thanks to all,
Moondancer - EE Moderator
0
 
LVL 28

Expert Comment

by:vinnyd79
ID: 7078721
Moondancer, look at the askers last comment:

>> Vinnyd79,

Your solution is the best to my problem.
Please propose answer to get the points.

Thank you.

--------------------------

That is why I proposed the answer to this question.
0
 
LVL 1

Expert Comment

by:kodiakbear
ID: 7523196
Dear vinnyd79
I've rejected your proposed answer as Experts Exchange holds an experiment to work without the answer button.

See: <http://www.experts-exchange.com/jsp/communityNews.jsp>
Paragraph: Site Update for Wednesday, November 06, 2002

By this rejection the Asker will be notified by mail and hopefully he will take his responsibility to finalize the question or post an additional comment.
The Asker sees a button beside every post which says "Accept This Comment As Answer" (including rejected answers) -- so if he/she thinks yours is the best, you'll be awarded the points and the grade.

EXPERTS: I will return in seven days to close this question.
Please leave your thoughts and recommendations here

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER !

Thanks !

kodiakbear
Experts Exchange Moderator
0
 
LVL 28

Expert Comment

by:vinnyd79
ID: 7525115
fyi,
the asker had asked me to propose it as an answer to get the points.

qoute:

"Vinnyd79,

Your solution is the best to my problem.
Please propose answer to get the points.

Thank you."
0
 
LVL 1

Expert Comment

by:kodiakbear
ID: 7525520
vinnyd79,
Sorry about that it was an automated program which I unlocked the questions with. :)
I have force accepted your comment.

kb
Experts Exchange Moderator
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

721 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