RetVal = Shell(BatFilePath, vbNormalFocus)
Where BatFilePath is a string variable with the full path of the batch file
(e.g., D:\...\Batchfile.bat)
The line executes – I get a value in the RetVal variable and I see a brief
flash of the command prompt window, but I do not see the file that the batch
file is supposed to produce. A search of my hard drives indicates that the
results have not been created in some unexpected location.
The batch file works properly when run manually.
OR
Dim strSheet as String
strSheet = Sheets("info").Range("F30")
Application.Goto Reference:=Sheets(strSheet).Range("A1")
--
If this post helps click Yes
---------------
Jacob Skaria
"Rick Rothstein" wrote:
> In older version of Windows (I thought this was changed in newer versions,
> but I haven't used Shell in ages, so I don't know for sure), you used to
> have to encase any path/filenames where either the path or filename
> contained internal spaces. You could try this and see if it works...
>
> RetVal = Shell("""" & BatFilePath & """", vbNormalFocus)
>
> Another possibility is that the briefly flashing command window is
> displaying an error message of some kind. I believe this line of code will
> leave the command window up so you can read its contents...
>
> RetVal = Shell(Environ$("comspec") & " /k " & """" & _
> BatFilePath & """", vbNormalFocus)
>
> --
> Rick (MVP - Excel)
>
>
> "D.riggins" <Drig...@discussions.microsoft.com> wrote in message
> news:0CF79E91-D12D-441D...@microsoft.com...
RetVal = Shell("""" & BatFilePath & """", vbNormalFocus)
Another possibility is that the briefly flashing command window is
displaying an error message of some kind. I believe this line of code will
leave the command window up so you can read its contents...
RetVal = Shell(Environ$("comspec") & " /k " & """" & _
BatFilePath & """", vbNormalFocus)
--
Rick (MVP - Excel)
"D.riggins" <Drig...@discussions.microsoft.com> wrote in message
news:0CF79E91-D12D-441D...@microsoft.com...
Steve Yandl
"D.riggins" <Drig...@discussions.microsoft.com> wrote in message
news:0CF79E91-D12D-441D...@microsoft.com...
>I am trying to run a batch file from Excell 2003 using the Shell function
>in
> VBA and I can't seem to get it to work. The code is like this:
>
> RetVal = Shell(BatFilePath, vbNormalFocus)
>
> Where BatFilePath is a string variable with the full path of the batch
> file
> (e.g., D:\...\Batchfile.bat)
>
> The line executes - I get a value in the RetVal variable and I see a brief
For now I've taken the brute force approach and changed the batch file so it
explicitly changes the directory before processing the rest of the commands
in the batch file. I'm wondering, though, if there is not a more elegant
means of doing this using the Environ command or some other command.
I'm a novice to programming and I'm sure I haven't used all the right
terminology but I hope I was able to convey my point. Any help would be most
Appreciated.
Regards,