473,387 Members | 1,541 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Need Call Shell to Open Selected File Using Default Program

Expand|Select|Wrap|Line Numbers
  1. Private Sub FilePath_Click()
  2.     Rem Me![AutoNumber]
  3.     Dim stAppName As String
  4.     Dim stlink As String
  5.         stlink = Me![FilePath]
  6.         stAppName = "C:\Program Files\Internet Explorer\IEXPLORE.EXE H:\Application\Cables\" + stlink
  7.         Call Shell(stAppName, 1)
  8. End Sub
After using the Common Dialog API to store a file name in a field "FilePath," I use the code above to click on FilePath to open the file associated with the file path. The stAppName above previously had a reference to Adobe Acrobat PDF, but some of my files are .htm files so I switched it to Internet Explorer (as shown above).

Problem: Not all of my files will be .htm extensions. Some may be .jpg, .bmp, .doc.... How can I force each file to open using its default program? I've tried deleting "C:\Program Files\Internet Explorer\IEXPLORE.EXE" and leaving the rest, but it doesn't work. The Call Shell code is clearly looking for an application to run.

Thanks in advance.
Dec 14 '07 #1
3 8122
Rabbit
12,516 Expert Mod 8TB
Use FollowHyperlink instead of call shell.
Dec 14 '07 #2
Use FollowHyperlink instead of call shell.
Again, thanks for the help, Rabbit. This is the code I used ultimately:

Expand|Select|Wrap|Line Numbers
  1. Private Sub FilePath_Click()
  2.     Rem Me![AutoNumber]
  3.     Dim stlink As String
  4.         stlink = Me![FilePath]
  5.         FollowHyperlink stlink, , true
  6. End Sub
I have a couple related problems that I've posted in their separate threads. I've searched on-line and tried changing the VB (unwittingly--my knowledge of VB is next to zero) to no avail. Those related problems are here:

Display File Title, Link Using File Path
http://www.thescripts.com/forum/show...94#post2984894

Follow Hyperlink, Then Set Focus to Linked App
http://www.thescripts.com/forum/show...12#post2984912

For anyone interested and/or knowledgeable, any additional help would be great.
Dec 14 '07 #3
ADezii
8,834 Expert 8TB
Expand|Select|Wrap|Line Numbers
  1. Private Sub FilePath_Click()
  2.     Rem Me![AutoNumber]
  3.     Dim stAppName As String
  4.     Dim stlink As String
  5.         stlink = Me![FilePath]
  6.         stAppName = "C:\Program Files\Internet Explorer\IEXPLORE.EXE H:\Application\Cables\" + stlink
  7.         Call Shell(stAppName, 1)
  8. End Sub
After using the Common Dialog API to store a file name in a field "FilePath," I use the code above to click on FilePath to open the file associated with the file path. The stAppName above previously had a reference to Adobe Acrobat PDF, but some of my files are .htm files so I switched it to Internet Explorer (as shown above).

Problem: Not all of my files will be .htm extensions. Some may be .jpg, .bmp, .doc.... How can I force each file to open using its default program? I've tried deleting "C:\Program Files\Internet Explorer\IEXPLORE.EXE" and leaving the rest, but it doesn't work. The Call Shell code is clearly looking for an application to run.

Thanks in advance.
You can use the ShellExecute() API Function to Open any File in its server Application and make it the Active App. If you are interested, let me know.
Dec 14 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Paolo | last post by:
Friends, I have created a form with a list box that shows all my Word files. I have then added the following code (found on comp.databases newsgroup) to the Open event of my form and it works...
6
by: joby mathai | last post by:
anybody please tell me how to read a .wav file using c program.when i do with the fopen statement a null value is returned.please tell me solution.
0
by: egp | last post by:
Hi guys, I have a database using Ms Access 2003 connected to VB6 using ADODB Connection and I want to know how to: - display Ms Access report in VB using VB code then print it out - backup and...
4
by: helloitsme | last post by:
Hello! I am trying to open a file that is selected by a user from the openfiledialog box, but the file does not open. Below is the part of the code that does so... ...
5
by: SelvaSA | last post by:
Hi All, I can able to create a excel file using POIFS plug-in from Jakarta, but i want open already created file from a selected location. Here i am pasting my code to generate excel file. ...
0
by: Sasie7679 | last post by:
Dear All, We have a requirement to open any file using a specific application and showing it within a activex control. For example, bmp file can be shown in Internet explorer, paint brush, photo...
2
by: andrei.avk | last post by:
Hi, I searched for this on google and in this group, but my awesome google-fu powers failed me. Is there a way to open any file using default program that'd open it? In other words, to do the same...
2
by: arivusudar.nc | last post by:
I have to open word document in web page using php coding in linux server.. already i worte in windows supporting php code. but it is not working in my linux server so, i need how to open word...
1
by: sanchit007 | last post by:
How can i open any file using voice command. Means that i say anything like open internet it perform a task....... How we can do through java programming
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.