Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 32
Default Simple Shell Commands

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


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 32
Default Simple Shell Commands

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





  #3   Report Post  
Posted to microsoft.public.excel.programming
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







  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 32
Default Simple Shell Commands

Hello Tom

The following continues to give me "file not found"

shell "chdrive " & ActiveWorkbook.path
shell "Chdir " & Activeworkbook.Path

This is really stumping me (it just shouldn't be this hard). Maybe I am
tired but... what is my problem?

"Tom Ogilvy" wrote in message
...
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









  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 32
Default Simple Shell Commands

Yes I think that is clear. My early questions were based upon naivete.
Thank you.

W
"Tom Lavedas" wrote in message
...
Your misinterpreting Mr. Ogilvy's suggestions. They (ChDir and ChDrive)

are internal of the Excel VBA methods and thus do not require the Shell. To
do that in a command shell requires the command processor, I discussed
earlier. However, changing them in the command shell does NOT cause the
referenced folder to change in the parent Excel environment. To do that you
must issue the statements per Mr. Ogilvy's post (without any reference to
the Shell method).

Does that clear it up?

BTW, that's NOT what your original post asked for.

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

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

Hello Tom

The following continues to give me "file not found"

shell "chdrive " & ActiveWorkbook.path
shell "Chdir " & Activeworkbook.Path

This is really stumping me (it just shouldn't be this hard). Maybe I

am
tired but... what is my problem?

"Tom Ogilvy" wrote in message
...
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



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Why 39 sec. delay for simple commands, Excel 2003? Thanks! fmes Excel Discussion (Misc queries) 1 December 19th 09 02:10 PM
Shell command MAx Excel Programming 2 June 4th 04 04:11 PM
Commands at the line prompt using Shell cogent Excel Programming 2 April 27th 04 04:56 AM
Shell Joseph[_12_] Excel Programming 1 February 1st 04 04:33 AM
Shell Statement Confused@424 Excel Programming 1 August 13th 03 08:19 PM


All times are GMT +1. The time now is 02:20 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"