Other

Quick Append Feature

Ease of Use

Intermediate

Version tested with

Win2k 

Submitted by:

mdewis

Description:

This code created in a VB Script File will quickly append all text or csv files that are dragged over it. You can also add to your C:\Documents and Settings\yourname\SendTo folder and any files you highlight in Explorer can be right clicked and sent to this script. 

Discussion:

This is a quick way to take multiple text or CSV files (perhaps daily data files) and append them to others to arrive at a large consolidated data file. ie. 30 daily data files could become your monthly data file. 

Code:

instructions for use

			

Const ForReading = 1 Set sa = CreateObject("Shell.Application") Set shFolder = sa.BrowseForFolder(0, "Select Folder to Save Output File", 0, "") If shFolder Is Nothing Then wscript.quit End If Set shFolderItem = shFolder.Items.Item folderName = shFolderItem.Path Output = InputBox("Enter Filename and Extension of Appended Output") If Output="" Then wscript.quit End If Set c = CreateObject("Scripting.FileSystemObject") Set d = c.CreateTextFile(foldername & "\" & Output) For Each strArgument In Wscript.Arguments If right(strArgument,4)=".xls" Then msgbox "Will Not Work With Excel Files. Please Convert to Text First" Set b = c.OpenTextFile(strargument, ForReading) readerline=b.readall d.WriteLine readerline Next

How to use:

  1. Paste the code into a text file using Notepad or Wordpad and save the file with a .vbs ending (extension). This will make it a VBScript file.
  2. Open Explorer, and highlight the files you wish to append.
  3. Drag the highlighted files over this script file and you will be prompted to ask where you want to save the new appended file.
  4. You will then have to enter the filename to save it as.
  5. You should now see an appended file where you saved it.
  6. *Don't try this with Excel files as it gets confused with multi-tabs.
 

Test the code:

  1. Extract APPENDER.VBS (contained in APPENDER.zip) file to C:\Documents and Settings\username\SendTo
  2. Highlight files to append together, right click selection, then choose Send To -> APPENDER.VBS
  3. Choose drive/directory to place appended file
  4. Enter appended file name
 

Sample File:

APPENDER.zip 0.52KB 

Approved by mdmackillop


This entry has been viewed 198 times.

Please read our Legal Information and Privacy Policy
Copyright @2004 - 2020 VBA Express