Wrox Programmer Forums
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 25th, 2007, 11:27 AM
Authorized User
 
Join Date: Apr 2007
Posts: 56
Thanks: 0
Thanked 0 Times in 0 Posts
Default Members of File System

Does anyone know a good resource to find a listing of the "Members of the File System"

I am trying to copy a file and do not know how to refer to the object

For example:

Dim fs As Object
Set fs = ?????this is what I don't know????
fs.CopyFile "c:\MyDocuments\*Kronos.txt", "c:\Processed\"

Thanks in advance.
Coby

 
Old April 25th, 2007, 01:36 PM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

I usually use something like this:

Dim objFSO As Variant

Set objFSO = CreateObject("Scripting.FileSystemObject")
If objFSO.FileExists(c:\MyDocuments\Kronos.txt") Then
   objFSO.MoveFile "c:\MyDocuments\Kronos.txt", "c:\Processed\"
End If

It looks like you want to move a file, not copy it. If you want to copy it then do this instead of MoveFile:

objFSO.CopyFile "c:\MyDocuments\*Kronos.txt", "c:\Processed\Kronos.txt"

If you are searching for a file and are using a wildcard, what you need to do is take the filename, and then check the Right(sFileName, 10) = "Kronos.txt"

Then do this:

objFSO.MoveFile "c:\MyDocuments\" & sFileName, "c:\Processed\"


Did that help?



mmcdonal
 
Old April 25th, 2007, 01:37 PM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

Sorry, that should have been:

objFSO.CopyFile "c:\MyDocuments\Kronos.txt", "c:\Processed\Kronos.txt"

with no wildcard character.

mmcdonal
 
Old April 25th, 2007, 01:42 PM
Authorized User
 
Join Date: Apr 2007
Posts: 56
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Yes! I am trying to move a file and this is very helpful.
I will try it. Where I was stuck before was trying to refer to the "MsWindows File System".
I didn't know what to call it. I am familiar with vba.filesystem or application. or access. etc, but not calling to windows.

Thanks.
Coby.

 
Old April 25th, 2007, 01:56 PM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

This is VBScript. It works within VBA, of course. So I always use it when I need to work with text files (reading data, moving, searching, etc.) Go to msdn and do a search for VBScript and there are all sorts of reference materials for free.


mmcdonal
 
Old April 25th, 2007, 03:07 PM
Authorized User
 
Join Date: Apr 2007
Posts: 56
Thanks: 0
Thanked 0 Times in 0 Posts
Default

That worked exactly how I wanted it to!

I appreciate your help.







Similar Threads
Thread Thread Starter Forum Replies Last Post
writing into a file in linux file system anboss XSLT 6 June 19th, 2008 01:56 PM
File system gandhi BOOK: Professional SQL Server 2005 Integration Services ISBN: 0-7645-8435-9 2 March 22nd, 2006 05:23 PM
PHP File System Wylzn BOOK: Beginning PHP4/PHP 5 ISBN: 978-0-7645-4364-7; v5 ISBN: 978-0-7645-5783-5 0 July 7th, 2004 07:05 AM
File System Watcher [email protected] VB.NET 12 June 4th, 2004 07:29 AM
File System Object kumar_rajeshk Pro VB 6 7 April 28th, 2004 01:35 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.