Shell command: Error 5

mtheriault2000

Well-known Member
Joined
Oct 23, 2008
Messages
826
Long time that I played with the Shell command. I keep getting Error 5.
I think that it is related to some space included in the path, but can't find how to resolved that yet.

The goal, start and external application when my Excel file is opened.
Code:
Private Sub Workbook_Open()     ' Setting a global variable

Dim retcode As Long
Dim StringBack As String
Dim Astring As String


Astring ="G:\Users\Utilisateur\Documents\Martin\Documents\Document Bourse\MultiChart\WorkSheet\1 Hour\4_ScalesChart\4Scales_Desktop.mcd"




retcode = Shell(Astring,1)

End Sub

Martin
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
How sure are you that file "G:\Users\Utilisateur\Documents\Martin\Documents\Document Bourse\MultiChart\WorkSheet\1 Hour\4_ScalesChart\4Scales_Desktop.mcd" exists? Does the code work if you replace it with notepad.exe for a test?

Code:
Private Sub Workbook_Open()     ' Setting a global variable

Dim retcode As Variant 'Long
Dim StringBack As String
Dim Astring As String


'Astring = "G:\Users\Utilisateur\Documents\Martin\Documents\Document Bourse\MultiChart\WorkSheet\1 Hour\4_ScalesChart\4Scales_Desktop.mcd"
Astring = "C:\Windows\System32\Notepad.exe"


retcode = Shell(Astring, 1)

End Sub
 
Upvote 0
You might also include the error text for any error you get. For example if I run your code I get a Runtime-error 53, which includes the error text "file not found" (because I don't have a 4Scales_Desktop.mcd file on my PC). The error text, in addition to the error number, can be helpful to anyone trying to assist.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,170
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top