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

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
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
OK, I will try when back home

When I copied the file string in the Windows search box, Windows did opened it
 
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,214,912
Messages
6,122,204
Members
449,072
Latest member
DW Draft

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