By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,061 Members | 1,523 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,061 IT Pros & Developers. It's quick & easy.

Need Call Shell to Open Selected File Using Default Program

P: 55
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
Share this Question
Share on Google+
3 Replies


Rabbit
Expert Mod 10K+
P: 12,366
Use FollowHyperlink instead of call shell.
Dec 14 '07 #2

P: 55
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
Expert 5K+
P: 8,638
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

Post your reply

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