Where?...How? -- SHELL w/ DOS commands - Having a TOUGH Time....

  • Thread starter kev100 via AccessMonster.com
  • Start date
K

kev100 via AccessMonster.com

I'm having a TOUGH time trying to get this going...

And what makes it so aggravating is that I'm sure it's something simple.....
I'm just not familiar enough with Access VBA, Modules, etc to do it.

After lots of reading on this board......it looks like the SHELL command is
what's needed.....but I can't figure out exactly how to implement it so that
it will execute when clicking a button on a form.

I'm needing to copy all the files in a specfic directory to another
directory.

All paths are static....the only variable will be the Name of the source
directory. The name of that given source directory is displayed in a text
box on the form.

This is the command that I think should do it:

Shell ("xcopy c:\MainDirectory\"& [forms]![MyForm]![DirTextBox] & "\*.* /s /y
C:\TargetDir")

However....I don't know WHERE / HOW to put/create this command (in a Macro...
in a Module...other...?) so that it can be activated by clicking a button on
the form.

I'm sure that must be really basic process...but I can't some to get things
going.

Any help appreciated.

Thanks
 
D

Douglas J. Steele

You'd call that in a module. However, Shell is a function: you're supposed
to have a variant variable to which you can assign its return value:

Dim varReturn As Variant

varReturn = Shell(...)

or else call it:

Call Shell(...)

As well, if there's a chance that what's in DirTextBox can contain spaces,
you'll need quotes around the folder details:

Shell ("xcopy ""c:\MainDirectory\"& [forms]![MyForm]![DirTextBox] & "\*.*""
/s /y C:\TargetDir")

In fact, since MainDirectory is more than 8 characters, you might want to do
that even if DirTextBox will never contain spaces.
 
K

kev100 via AccessMonster.com

Thanks very much....

Things seem to be working now....

When the process runs, that dirctory name is passed to the xcopy command and
the files get copied.

When it runs.....the command window will open (and stays open....which it
needs to do)....but it is Minimized at the bottom.

The user needs the visual feedback that the files were copied (or not)....so
they can know when (if) they can continue with the task.

When it is minimized....they really don't know what happened.

I tried the "/q" switch with Shell Environ$("COMSPEC").....but it causes an
error. Using the "/k" switch causes the command window to remain open after
copying the files....but it is minimized.

Is it possible for that command window to show on top of the others....
initially?

Thanks very much.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top