+ Reply to Thread
Results 1 to 5 of 5

Batch Excel Script, without running Excel?

  1. #1
    Registered User
    Join Date
    06-08-2013
    Location
    Sweden
    MS-Off Ver
    Excel 2013
    Posts
    20

    Batch Excel Script, without running Excel?

    Okay i recently got my code to work very well, thanks to help here in my earlier thread.

    And i want to advance it one step further.

    I would like to run my script on every .csv file and then produce a text file from it.
    I already have the code to do it on 1 file, the file i open up and run the script on.

    But i would like to do it without Excel opening, and just from a script, which seems to work from my searching.

    I am currently using:

    Please Login or Register  to view this content.
    Which i pretty much copied from the net, and changed to suit my needs.

    But it canīt run the Sheet1.sync script, i get an error.

    Now my script is pretty messed up, and uses Userform (GUI), which i guess may mess up the VBA script from running, though i am not sure.

    I will copy the codes here, if you see things that can be improved (which you probably will) then please post it as well.

    Sheet1
    Please Login or Register  to view this content.
    UserForm1
    Please Login or Register  to view this content.
    Module11
    Please Login or Register  to view this content.

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Batch Excel Script, without running Excel?

    Hello zerowalker,

    It looks like you are using the UserForm to create a command line used in the code to copy the CSV into a TXT file.

    Question is do the commands in the command line change or just the file name and path?

    If the answer to the question above is just the file name and path then a script can be constructed to copy the CSV files into TXT files.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Registered User
    Join Date
    06-08-2013
    Location
    Sweden
    MS-Off Ver
    Excel 2013
    Posts
    20

    Re: Batch Excel Script, without running Excel?

    Yes, Public Sub UserForm_initialize() to be precise.

    And what i do is do a calculation, and then i want to write the results to a file.

    I am not trying to convert CSV to TXT though.

    I am really not trying to make a TXT file, but rather a AVS file, but as the content is the same (ASCI Characters) i said TXT.
    But as said, it doesnīt matter, the type allows the same content to be used.


    But that being said, i am having some options in a my Userform, so i need to tell it to use certain settings (for example, i need to tell it that s = something), i do this with option buttons.

    Please Login or Register  to view this content.
    There for example.


    Now i am not sure if a Userform window can be used in a script without Excel.

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Batch Excel Script, without running Excel?

    Hello zerowalker,

    If you post your workbook then I can better understand what you are doing without a lot of questions and answers. Please include some before and after examples of the file results. If you have any sensitive data in the workbook, please redact it before posting.

  5. #5
    Registered User
    Join Date
    06-08-2013
    Location
    Sweden
    MS-Off Ver
    Excel 2013
    Posts
    20

    Re: Batch Excel Script, without running Excel?

    Sure here it is:13-07-1(2).txt13-07-1(2).csvPERSONAL.XLSB

    i changed a bit of the .txt file to xxx, where the file path is.
    Itīs automatically written as it just copies the path and name from the active workbook, and only changes the name (csv to "xxx" whatever i want)


    EDIT: The Batch button and code is just added for my testing to batch through using the excel macro, so it can be ignored.
    Last edited by zerowalker; 07-07-2013 at 12:15 AM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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