+ Reply to Thread
Results 1 to 15 of 15

Auto Create Files From List

  1. #1
    Registered User
    Join Date
    08-23-2011
    Location
    UK
    MS-Off Ver
    Excel 2003
    Posts
    11

    Auto Create Files From List

    Hi

    I have a list of several thousand names, each of which need to be turned into a file with a .php suffix, is this possible using excel? All the file contents will be identical as the information is generated using the file name.

    Thanks in advance

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Auto Create Files From List

    Yes, all is possible. VBA just needs specific instructions, as do we to offer specific help.

    Post some sample data and possibly example "results" workbook. Click GO ADVANCED and use the paperclip icon to post up a copy of your workbooks.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Registered User
    Join Date
    08-23-2011
    Location
    UK
    MS-Off Ver
    Excel 2003
    Posts
    11

    Re: Auto Create Files From List

    I have attached the spreadsheet and the information I want contained in the new files. I would behoping to create a separate file for each line from the workbook, containing the code in the .txt file. I don't have any experience with VBA, so I hope this is what you were asking for.

    Thank you so much for your help!
    Attached Files Attached Files

  4. #4
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Auto Create Files From List

    I looked through the sample TXT file and can't spot what/where the "changes" would be for each row of the XLS file. Can you clarify?

  5. #5
    Registered User
    Join Date
    08-23-2011
    Location
    UK
    MS-Off Ver
    Excel 2003
    Posts
    11

    Re: Auto Create Files From List

    Hi, thanks for replying.

    I just intend to create a new .php file (I uploaded .txt as it wouldn't allow .php) for each line in excel spreadsheet. So the first file would be atuk.php and would contain the text from the .txt file, and so on for each line on the excel spreadsheet, so in total there would be 3000 or so .php files, each with a different name containing the same text.

    Thanks for you help

  6. #6
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Auto Create Files From List

    Oh, you mean create COPIES of an existing text file that's in a folder somewhere? Why didn't you say so?

    The FileCopy method makes this pretty simple.

    Please Login or Register  to view this content.
    Just edit those strings to list the original fPath where the codes.txt file is located, and the DestPath where you want all these created files to end up.
    Last edited by JBeaucaire; 08-26-2011 at 10:02 AM. Reason: Typos... thanks Watersev

  7. #7
    Registered User
    Join Date
    08-23-2011
    Location
    UK
    MS-Off Ver
    Excel 2003
    Posts
    11

    Re: Auto Create Files From List

    Thank you so much

  8. #8
    Registered User
    Join Date
    08-23-2011
    Location
    UK
    MS-Off Ver
    Excel 2003
    Posts
    11

    Re: Auto Create Files From List

    Please Login or Register  to view this content.
    I used the above code but it says Compile error: Variable Not Defined

    I have no experience of VBA so I may be doing something really basic wrong.

    Sorry I am taking so long to get it!

  9. #9
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Auto Create Files From List

    By removing the OPTION EXPLICIT at the top, you turned off the "code checker" which would have pointed you to the DestPath string. You accidentally moved the second " to the end of the comment instead of the end of the path.
    Please Login or Register  to view this content.

  10. #10
    Registered User
    Join Date
    08-23-2011
    Location
    UK
    MS-Off Ver
    Excel 2003
    Posts
    11

    Re: Auto Create Files From List

    Hi

    Sorry I did have the Option Explicit but missed it out accidentally. The code is now:


    Please Login or Register  to view this content.
    but still has the error message. If it is any help it highlights and points to Sub MakeCopies()

    Thanks

  11. #11
    Forum Expert
    Join Date
    11-29-2010
    Location
    Ukraine
    MS-Off Ver
    Excel 2019
    Posts
    4,168

    Re: Auto Create Files From List

    hi, gilgil2, there are some misprints in the code:

    1.
    Please Login or Register  to view this content.
    should be read
    Please Login or Register  to view this content.
    2.
    Please Login or Register  to view this content.
    should be read
    Please Login or Register  to view this content.

  12. #12
    Registered User
    Join Date
    08-23-2011
    Location
    UK
    MS-Off Ver
    Excel 2003
    Posts
    11

    Re: Auto Create Files From List

    Please Login or Register  to view this content.
    I now get a run time error 76: Path not Found, I assume this is something to do with me entering the wrong file paths, but I have checked and checked but can't see the problem. I am using a Mac, does this make a difference? Can you see if there is an obvious problem there?

    Thanks

  13. #13
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Auto Create Files From List

    Yes, the error message states the issue.

    On a PC, I can navigate in Windows Explorer to the code.txt file and right-click the file to get/copy the full path to the file properly. Can you do something like that on a mac?

  14. #14
    Registered User
    Join Date
    08-23-2011
    Location
    UK
    MS-Off Ver
    Excel 2003
    Posts
    11

    Re: Auto Create Files From List

    Please Login or Register  to view this content.
    Thanks, I did that and it took off the C: but now it comes up with error 75, any idea why this is?

  15. #15
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Auto Create Files From List

    Probably because you need a "C". Sorry, I have no knowledge of file requirements on a Mac.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1