excel - Run-time error when using the 'Run' method of the 'WScript.Shell' object -


i'm trying run command prompt via vba execute couple of commands, have run in error.

run-time error '-214702894(80070002)':
method 'run' of object 'iwshshell3' failed

i have tried wrapping file paths in quotes (as below), error persists ever method use.

shell.run "cd """ & mydocumentspath & """", 1, true shell.run "cd " & chr(34) & mydocumentspath & "chr(34)", 1, true 

i tried directly type file path (with no spaces), failed too.

shell.run "cd ""c:\users\gardd""", 1, true 

is able spot issues? here full code -

dim shell object ' instance of 'shell' object set shell = vba.createobject("wscript.shell")  dim mydocumentspath string   ' path current users 'my documents' folder mydocumentspath = getmydocumentspath  shell.run "cd " & mydocumentspath, 1, true  ' change shell start location users 'my documents' folder shell.run dir_cmd & dir_file_path, 1, true  ' output full file paths of files in users 'my documents' folder  set shell = nothing ' destroy 'shell' object 

cd not executable; command exists within (cmd.exe) console session, ditto dir if that's what's in dir_cmd.

you shell.run "cmd /c cd c:\temp & dir *.xls", 1, true

probably better use vba whatever want @ command line.


Comments

Popular posts from this blog

qt - Using float or double for own QML classes -

Create Outlook appointment via C# .Net -

ios - Swift Array Resetting Itself -