Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Move Full Directories

Status
Not open for further replies.

tonyj

Technical User
Nov 7, 2000
2
US
How can i through code in Access move full directories. the FileCopy command does not work with wildcards.
 
I am not sure, but I thought you could execute shell commands. If you can, then maybe that is a way to go.

I'll try to hunt around in the help.


Terry M. Hoey
th3856@txmail.sbc.com

Ever notice that by the time that you realize that you ran a truncate script on the wrong instance, it is too late to stop it?
 
The following is the help for the Shell command:
Code:
Runs an executable program and returns a Variant (Double) representing the program's task ID if successful, otherwise it returns zero.

Syntax

Shell(pathname[,windowstyle])

The Shell function syntax has these named arguments:

Part	Description
pathname	Required; Variant (String). Name of the program to execute and any required arguments or command-line switches; may include directory or folder and drive.
windowstyle	Optional. Variant (Integer) corresponding to the style of the window in which the program is to be run. If windowstyle is omitted, the program is started minimized with focus.
The windowstyle named argument has these values:

Constant	Value	Description
  
vbHide	0	Window is hidden and focus is passed to the hidden window.
vbNormalFocus	1	Window has focus and is restored to its original size and position.
vbMinimizedFocus	2	Window is displayed as an icon with focus.
vbMaximizedFocus	3	Window is maximized with focus.
vbNormalNoFocus	4	Window is restored to its most recent size and position. The currently active window remains active.
vbMinimizedNoFocus	6	Window is displayed as an icon. The currently active window remains active.
Remarks

If the Shell function successfully executes the named file, it returns the task ID of the started program. The task ID is a unique number that identifies the running program. If the Shell function can't start the named program, an error occurs. If you use the MacID function with Shell in Microsoft Windows, an error occurs.

Note   The Shell function runs other programs asynchronously. This means that a program started with Shell might not finish executing before the statements following the Shell function are executed.
I am not sure if that will help or not, but it may be worth a try.

Hope it helps...

Terry M. Hoey
th3856@txmail.sbc.com

Ever notice that by the time that you realize that you ran a truncate script on the wrong instance, it is too late to stop it?
 
Look up the FileSystemObject. It has a bunch of methods for doing jobs with the file system one of which includes copying a folder. Strangely enough this method is called 'copyfolder'.:) Durkin
alandurkin@bigpond.com
 
Durkin,

I looked through the help files and the book that I have and I can't find anything on FileSystemObject. Is there any chance you can paste some info on it here?

Thanks...


Terry M. Hoey
th3856@txmail.sbc.com

Ever notice that by the time that you realize that you ran a truncate script on the wrong instance, it is too late to stop it?
 
This is the page from the Access help:

Description

Provides access to a computer's file system.

Syntax

Scripting.FileSystemObject

Remarks

The following code illustrates how the FileSystemObject is used to return a TextStream object that can be read from or written to:

Set fs = CreateObject("Scripting.FileSystemObject")
Set a = fs.CreateTextFile("c:\testfile.txt", True)
a.WriteLine("This is a test.")
a.Close

In the code shown above, the CreateObject function returns the FileSystemObject (fs). The CreateTextFile method then creates the file as a TextStream object (a), and the WriteLine method writes a line of text to the created text file. The Close method flushes the buffer and closes the file.




The URL for the page at msdn is

Durkin
alandurkin@bigpond.com
 
I see from that path that this is a Visual Studio 6 function. Is it in Access, too? I'll try to find it.

But, thanks for the info.


Terry M. Hoey
th3856@txmail.sbc.com

Ever notice that by the time that you realize that you ran a truncate script on the wrong instance, it is too late to stop it?
 
The page I pasted into my previous message is straight from the help in Access 2000. If you are using Access 97 it's possible that it's not in there. Anyway, you can definitely use it in Access - I have done it before. Durkin
alandurkin@bigpond.com
 
thanks everyone for the help. i found that by using the shell command and comspec i could make this work. her is the code if anyone else is interested. keep in mind the source directory and destination directory are for my program and will not apply to yours.

Shell (Environ$("COMSPEC") & " /c move \\Nustyle\Files\" & vstatus & "\" & vProjectName & " " & "\\Nustyle\Files\Completed\" & vProjectName)
 
tonyj,

Be aware that this - and most/all Windows based approaches will not copy 'open' files. You need to be careful using this approach, as the function may not complete the move if there are open files in the source directory.



MichaelRed
mred@duvallgroup.com
There is never time to do it right but there is always time to do it over
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top