Results 1 to 9 of 9
  1. #1
    New Lounger
    Join Date
    Jul 2002
    Location
    Dallas, TX
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Batch Files & Macros (Access/97)

    I am just learning how to write batch files in DOS. Is there a way I can write a batch file that will use the file name in one of my controls on a form? I know I can run a batch file from a macro using RunApp, because I have tested it and it runs the batch file quite nicely. For example, if I have a file named TestFile.txt in a control on my form, and want to have a button that runs a macro to import my file and then rename it using the batch file. Is this possible in any way? I am very new to batch files and uncertain of even how to ask the question, but I hope you can make some sense out of it.

    Thanks in advance to anyone who can help.

    -Ronnie =)

  2. #2
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Batch Files & Macros (Access/97)

    What exactly are you trying to do in a batch file ... and why? If you want to rename the file, you can do that from within Access without using a batch file at all.
    Charlotte

  3. #3
    New Lounger
    Join Date
    Jul 2002
    Location
    Dallas, TX
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Batch Files & Macros (Access/97)

    Thanks Charlotte! I thought there might be a way to rename or move files with code....but of course, I am not a programming genius. Do you know of any sources where I might be able to get the coding structure to do this operation?
    I would appreciate any thoughts. And by the way, I have seen your replies to posts before and I just wanted to compliment you on your willingness to help others. You and Gary Swanson are really great folks! Thanks again! =)

  4. #4
    Silver Lounger GARYPSWANSON's Avatar
    Join Date
    Aug 2001
    Location
    Frederick, Maryland, USA
    Posts
    1,788
    Thanks
    0
    Thanked 2 Times in 2 Posts

    Re: Batch Files & Macros (Access/97)

    ... Thanks for the compliment... <img src=/S/grin.gif border=0 alt=grin width=15 height=15>

    Perhaps if you can be more specific on what you are trying to do, we can provide some more assistance. As Charlotte indicated, you can do this directly from access without the need for a batch file. I have only used batch files as a work around to do things in other apps (i.e,. MS Project) when I could not get the code to work. It is much easier if you can do what you want directly from Access.
    Regards,

    Gary
    (It's been a while!)

  5. #5
    New Lounger
    Join Date
    Jul 2002
    Location
    Dallas, TX
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Batch Files & Macros (Access/97)

    Okee dokee. I have some files that I am importing into a database using a main form as my import engine. The main form has a control the houses the file name after I search for it. (if that makes any sense.) Anyhow, I would like to add to my macro the following:

    After the import has completed, use the file name and path in the control on the form and rename it adding the following "_Completed" to the end of it before the file extension. Then move the file to another folder in the same directory for archive purposes. I hope that description is fairly understandable. I am not always the greatest at being eloquent with techinical jargon....heh heh [img]/forums/images/smilies/wink.gif[/img]

  6. #6
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Batch Files & Macros (Access/97)

    If you're using "macro" in the sense it's used in the rest of Office, post the code you're using and we'll help you tweak it. If you're talking about actual macros in the Access sense, it would be difficult. It would be far easier to do in code by simply copying the file to the new name and then deleting the old file. You could use the mid or Left function to return all but the period and extension, concatenate that to "_Completed" and concatenation that to the right 4 characters of the original file name something like this:

    strNewName = Left(strOldName, Len(strOldName)-4) & "_Completed" & Right(strOldName,4)

    FileCopy strOldName, strNewName

    Note that you need a full path and filename in both the source and destinateion file names.
    Charlotte

  7. #7
    New Lounger
    Join Date
    Jul 2002
    Location
    Dallas, TX
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Batch Files & Macros (Access/97)

    OK, well I figured as much with Access Macro difficulty. Yes, I have created a macro in Access not using code. I have not learned much code, but have been successful at making several databases without it. However, the more complex it gets, obviously the more I need code. Do you have any recommendations on a good source I can purchase to learn the structure of the VB code. I have basic understanding of how the syntax works and have created some good "IIf Statements" in queries and such. They are very short and basic, but took me a while to figure out on my own. I am very excited about the possibilities that VB offers and would like to start learning more. Alas, I am too advanced to start any beginner classes and not advanced enough to start any advanced classes. What would any of you recommend. I appreciate all your help and knowledge. Thanks =)

  8. #8
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Batch Files & Macros (Access/97)

    I wouldn't assume I was too advanced for beginner classes if I were you. Creating IIf statements in queries has very little to do with writing VBA code. You could start by using the wizard to convert some of your macros to code to give you a rough idea of equivalents, but the result won't be pretty. The Access wizards (clear up to XP) still write Access 95 code, the first version that used VBA as its programming language. Apparently they decided that once they had created them once, there was no point in updating. <img src=/S/shrug.gif border=0 alt=shrug width=39 height=15>

    If you're looking for books, do a lounge search in this forum on books and you'll find plenty of discussions on that topic.
    Charlotte

  9. #9
    New Lounger
    Join Date
    Jul 2002
    Location
    Dallas, TX
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Batch Files & Macros (Access/97)

    Okee dokee....well thanks for your input. I will do a search. Thanks [img]/forums/images/smilies/smile.gif[/img]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •