Error running Shell object / commands through Excel VBA Error running Shell object / commands through Excel VBA vba vba

Error running Shell object / commands through Excel VBA


The error does come from the directory having a space in it:

C:\Users\myname\this is my folder\myexe.exe

A simple workaround does the trick:

wsh.Run(Chr(34) & YourFullPathDirectoryWithSpaces & "\myexe.exe" & Chr(34))

Chr(34) is a double quote.

There was an issue with .Run taking a two line property.

Tested it on Excel 2010/Win32.


Had the same problem, alternative solution:

wsh.CurrentDirectory = exePathwsh.Run(exeName & " " & cmdArgs, windowStyle, waitOnReturn)

Key point being to set the CurrentDirectory property of the shell


I have determined that the problem appears entirely due to the directory structure including a space. There does not appear to be any issue relating to the local vs. shared directory.

If someone knows an easy fix to get around the directory having a space in it, please let me know!