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

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
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,223,888
Messages
6,175,208
Members
452,618
Latest member
Tam84

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