Hi!

I've just begun to see the potential of the VB software built into the Microsoft Office suite and am trying my hands on writing a macro that will automate a process for me.

Here's what I'm trying to do... I have a text file which contains a list of phrases I use for advertising purposes. I want to be able to automatically add another phrase at the end of each line in the text file.

So far I've managed to record a macro to open the original text file, write a formula that creates a new column containing the original phrases with the new phrase, copy and paste this column into a new book and then save that sheet as a new text file.

Here's the code that accomplishes this...

VB Code:
  1. Sub Macro1()
  2. '
  3. ' Macro1 Macro
  4. ' Macro recorded  by Zahid
  5. '
  6.  
  7. '
  8.     Workbooks.OpenText Filename:= _
  9.         "C:\Documents and Settings\Zahid\My Documents\input.txt" _
  10.         , Origin:=437, StartRow:=1, DataType:=xlDelimited, TextQualifier:= _
  11.         xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, Semicolon:=False, _
  12.         Comma:=False, Space:=False, Other:=False, FieldInfo:=Array(1, 1), _
  13.         TrailingMinusNumbers:=True
  14.     Range("B1").Select
  15.     ActiveCell.FormulaR1C1 = "=RC[-1]&"" london"""
  16.     Range("B1").Select
  17.     Selection.AutoFill Destination:=Range("B1:B3")
  18.     Range("B1:B3").Select
  19.     Columns("B:B").Select
  20.     Selection.Copy
  21.     Workbooks.Add
  22.     Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
  23.         :=False, Transpose:=False
  24.     Application.CutCopyMode = False
  25.     ActiveWorkbook.SaveAs Filename:= _
  26.         "C:\Documents and Settings\Zahid\My Documents\output.txt", FileFormat:=xlUnicodeText _
  27.         , CreateBackup:=False
  28. End Sub

Now, here's the hard bit...

I need the macro to be able to repeat this process for multiple files!

In other words, I would specify either in the macro, or be prompted somehow, the text files that I need processed. The macro will then process each file and save new text files for each file that it processes.

I guess my question is, is this possible with Visual Basic, and if so, how in the world do I do that?

Thanks in advance!