Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
|
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 June 25th, 2004, 11:31 AM
Registered User
 
Join Date: Jun 2004
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Access 97 VBA: Change file extensions

I have files with a .del extension.

I want to create a module that copies all files
to a new folder and converts the .del extension to
.txt
1. I know how to copy all files from one directory to another
2. I now need to take that directory of files and rename all from *.del to *.txt without knowing or typing each file name.

They are very large files. So I don't want to open them.
thanks

thanks

Dana
 
Old June 25th, 2004, 02:42 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,093
Thanks: 1
Thanked 12 Times in 11 Posts
Default

There are a bunch of ways to parse the source file name, but this might get it for you:

Sub CopyFiles(strFilesToCopy As String, strDestinationDirectory As String)

    ' Call with CopyFiles "C:\Test\*.del", "C:\Test2"

    Dim strSourceFile As String
    Dim strDestinationFile As String
    Dim strSourceDirectory As String ' "C:\Test\"

    strSourceDirectory = Left$(strFilesToCopy, (InStr(strFilesToCopy, "*") - 1))

    strSourceFile = Dir(strFilesToCopy)

    Do While strSourceFile <> ""

        strDestinationFile = Replace$(strSourceFile, ".DEL", ".TXT")
        FileCopy strSourceDirectory & strSourceFile, strDestinationDirectory & "\" & strDestinationFile

        strSourceFile = Dir

    Loop

End Sub

HTH,

Bob

 
Old December 1st, 2005, 02:23 PM
Registered User
 
Join Date: Dec 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I don't know if this guy ever got helped with this, but this was very helpful to me. Just wanted to let you know, in case you still checked on this one.

"For whosoever shall call upon the name of the Lord shall be saved." Romans 10:13
I'm glad He said whosoever!





Similar Threads
Thread Thread Starter Forum Replies Last Post
vba file access rema Excel VBA 0 August 28th, 2008 05:03 AM
Change the Appearance of a list box (Access VBA) hewstone999 Access VBA 1 February 29th, 2008 09:12 AM
Protect / Unprotect Excel 97 - VBA Code - jlpazv Excel VBA 2 November 30th, 2007 10:54 AM
VBA Forms (Access 97) timmaher Access VBA 5 September 7th, 2003 05:37 AM
File Extensions nbnelson C# 2 August 25th, 2003 12:09 PM





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