1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Solved: Create a sequential list

Discussion in 'Business Applications' started by CTPhil, Aug 28, 2007.

Thread Status:
Not open for further replies.
Advertisement
  1. CTPhil

    CTPhil Thread Starter

    Joined:
    Jan 5, 2006
    Messages:
    224
    Hi, I don't even know if what I want to do is possible.

    I'm creating an html slideshow with over 600 entries, so I need to list all of the file names in the code, separated by a comma. The file names are all the same except for the numbers being sequential. Example: slide001,slide002,slide003,... Is there any program that can generate a text file like this? Typing this out would be incredibly tedious.

    Thanks in advance.
     
  2. Zack Barresse

    Zack Barresse

    Joined:
    Jul 25, 2004
    Messages:
    5,452
    Yes, VBS can do this for you. Even VBA inside an Office application could. Can you explain to us where you want to run this from and where you want the output to be? I'm a little confused about how you need all of this information inside code. Maybe you could also tell us why you need this text in code?
     
  3. CTPhil

    CTPhil Thread Starter

    Joined:
    Jan 5, 2006
    Messages:
    224
    What is VBS? The slideshow I'm doing has a server side script that loads the images one at a time, using a list contained in a <script> element in the page's code. I don't know much more than that, I'm not a real code expert, just following some instructions.

    I don't need any code, just a list.
    OK, I figured out Visual Basic, but have no idea what it is.
     
  4. Zack Barresse

    Zack Barresse

    Joined:
    Jul 25, 2004
    Messages:
    5,452
    What language are you running? Can you just run a loop? If so, create a variable and iterate those changes in the loop in your code. Or do you want an actual text file listing those string values of your filenames?
     
  5. Zack Barresse

    Zack Barresse

    Joined:
    Jul 25, 2004
    Messages:
    5,452
    Oh, and VBS is Visual Basic Script. It's a code language you can write in Notepad (generally, for me) and run as such. I like it because it is portable, you only need Windows Script Host to run (defualt install in most Windows operating systems) and you can get the script files to run as a scheduled task. Plus it is easy to automate Office apps through it.
     
  6. CTPhil

    CTPhil Thread Starter

    Joined:
    Jan 5, 2006
    Messages:
    224
    Just the text file. I already have the code, I've used it for another show already, so I just want to duplicate that with a different list of filenames.
     
  7. CTPhil

    CTPhil Thread Starter

    Joined:
    Jan 5, 2006
    Messages:
    224
    The slideshow I'm copying is here.
     
  8. Zack Barresse

    Zack Barresse

    Joined:
    Jul 25, 2004
    Messages:
    5,452
    Well, this is VBA code you can run (I ran from within Excel)...

    Code:
    Sub CreateTextFileForMePlease()
        Dim i As Long
        Open "C:\Documents and Settings\UserName\Desktop\SlideShowFileNames.txt" For Output As 1
        For i = 1 To 600
            Print #1, "slide" & Format(i, "000")
        Next i
        Close #1
    End Sub
    Obviously, change the path to what you would like. Or were you not looking to use an Office application?
     
  9. CTPhil

    CTPhil Thread Starter

    Joined:
    Jan 5, 2006
    Messages:
    224
    Thanks, I can try it in Excel. I need a little help getting started, once in the VB editor, what do I do with the code you provided? Sorry to be a pain.
     
  10. Zack Barresse

    Zack Barresse

    Joined:
    Jul 25, 2004
    Messages:
    5,452
    Open the VBE (pressing Alt + F11), go to Insert | Module. Paste the code into that module pane (right code pane), click in it with your cursor (so that procedure has focus) and press F5. Make sure you change the file path before you run it though!
     
  11. CTPhil

    CTPhil Thread Starter

    Joined:
    Jan 5, 2006
    Messages:
    224
    I think I got it! Now I have to figure out how to display it horizontally, it's in a column. I added a comma before the file name, that seemed to work to get the comma in. Adding it after the numbers just defeated the task.

    Is there something that could be put in your code to output horizontally? slide1,slide2,etc...
    I can't seem to change it from:
    ,slide1
    ,slide2
    ,slide3
     
  12. Zack Barresse

    Zack Barresse

    Joined:
    Jul 25, 2004
    Messages:
    5,452
    What? How would you like the data formatted?
     
  13. Zack Barresse

    Zack Barresse

    Joined:
    Jul 25, 2004
    Messages:
    5,452
    Oh, and btw, if you wanted this run in a text file with VBS, you would use this in a Notepad file...

    Code:
    DIM fso, myFile, i
    Set fso = CreateObject("Scripting.FileSystemObject")
    Set myFile = fso.CreateTextFile("C:\Documents and Settings\UserName\Desktop\SlideShowFileNames.txt", True)
    For i = 1 to 600
        myFile.Write ("slide" & String(3 - Len(i), "0") & i & ",")
    Next
    myFile.Close
    Then save as whatever name you want, but add the extension ".vbs" instead of ".txt" or omitting. It will give you a slightly different file. Now just double click the file. Don't forget to change the path as well again.

    I've uploaded a sample file for you. Change the path in it (right click it, select Open With, choose Notepad, save/close normally, then run).
     

    Attached Files:

  14. Rollin_Again

    Rollin_Again

    Joined:
    Sep 4, 2003
    Messages:
    4,912
    Why don't you just generate the list in Excel and then save the Excel file as text format? You can use Excel's built in "Fill Series" function to generate the list of numbers and then use a simple formula to concatenate the slide name. If you want the names to go across the page horizontally you can copy into Word and do a find and replace. Just search for the paragraph mark (^p) and replace with a comma. Then just re-save as text


    Regards,
    Rollin
     
  15. CTPhil

    CTPhil Thread Starter

    Joined:
    Jan 5, 2006
    Messages:
    224
    OK, I'm lost. I created the Notepad file and saved it with a .vbs extension. When I pasted it into the Module in Excel, I got this error:
    What did I do wrong? Is it possible that there is a missing sub statement?
     
  16. Sponsor

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Loading...
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/616473

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice