Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hi Guys,
I have a fairly simple VB question. Can anyone tell me the code I would need so that when a command button is clicked it will run the .exe file on another program that is located on my 'c:\' drive.Thanks in advance guys.
Bertyzz

Private Sub Command1_Click()
Shell ("C:\QB45\qb.exe")
End Sub
That just an example, just plug whatever file you want in.

Hi Thanks Jason, that works a treat :)
The code works great for .exe files but I also need to open .PDF & .HTML files. Can you give me any more advice?
Thank you.

Private Sub Command1_Click()
A = "C:\Program Files\Adobe\Acrobat 5.0\Reader\AcroRd32 "
B = "C:\math122\Quiz3.pdf"
C = A + B
Returnval = Shell(C, 3)End Sub
Above the "A" is the place of the program that can open whatever file."B" is the place of the file you want to open
"C" just puts them together
Do the same with Internet html pages, just find IE and do something similiar as above.

Hi Jason,
Thanks for your help mate but I tried doing what you suggested above but I keep getting a 'Run-time error '5' message appering and,'Returnval = Shell(C, 3)'
is highlighted in yellow. As I am still rather ne wto VB I dont know how to rectify this problem, do you have any more ideas you could throw my way? Just incase you may be able to see if I have done somthing wrong I have put the code I have used below:
Private Sub Command2_Click() 'open pdf filesA = "E:\Adobe Maker\Acrobat\Adobe Acrobat 5.0 "
B = "F:\My Cds\Technician Ad\Tech Cd\IT Systems Support Course\UNIT 1 ITSST.pdf"
C = A + B
Returnval = Shell(C, 3)
End Sub
Thanks again for all you help.

Instead of writing
A = "E:\Adobe Maker\Acrobat\Adobe Acrobat 5.0 "you should write
A = "E:\Adobe Maker\Acrobat\AcroRd32.exe"
or whatever the name of the program is
try to find the executable file through my
computer and then puth the full path in A =

Hi guys,
Thanks to everyone for their help but I'm still having the same error!Ive decided to make the application a bit easier, insead of actually running the .exe file from the VB program, I am going to open the folder where the .exe file is located and then just click on the .exe file to run it.
Can anyone tell me the code to do this?
Thanks alot guys.
Bertyzz

![]() |
Adding a web site to sear...
|
How did they make spyware...
|

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |