View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Simple Shell Commands

chdrive ActiveWorkbook.path
Chdir Activeworkbook.Path

--
Regards,
Tom Ogilvy

"cogent" wrote in message
...
Hello

Thank you for your comments.

Really all I wanted to do was to change to the directory of the active
workbook. This should work:

Shell "CD /D" & activeworkbook.path

but it does not. What am I doing wrong?

W

"Tom Lavedas" wrote in message
...
Unles you are doing this exclusively on a Win 95/98/Me equipped machine,

you should not use the Command.com command processor. In fact, the best
thing would be to use the system defined %COMSPEC% environment variable to
locate the command processor in all casses. It keeps things neat and

tidy,
regardless of the OS version in use.

More specifically, I believe you need a statement like this ...

Shell "%comspec% /c CD" & activeworkbook.path & _
" | copy dest.txt+source.txt dest.txt /b"

This runs the statement ...

CD activeworkbook_path | copy dest.txt+source.txt dest.txt /b

as it would from the command prompt. Note that relative addressing

requires the removal of the absolute drive pathspecs from all of the file
names in the COPY statement.

Tom Lavedas
===========

----- cogent wrote: -----

Hello

Quick help, please.

In the following command:

Shell "command.com /c" & _
"copy c:\dest.txt+c:\source.txt c:\dest.txt /b"

what does the Shell "command.com /c" accomplish?

I am running shell commands that I want to make sure are executed

with the
active path at the prompt so that the commands behind it are able

to
be
effected on a RELATIVE basis. How?

Like this:?

Shell "command.com " activeworkbook.path & _
"copy c:\dest.txt+c:\source.txt c:\dest.txt /b"

The macro is run in a thumb drive where the drive number may vary,

but the
shell commands must be executed in the directory on the thumb

drive.

Please help.

W