|
-
Oct 17th, 2005, 03:56 PM
#1
Thread Starter
New Member
Plz help a VB dummy with his first project...
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:
Sub Macro1()
'
' Macro1 Macro
' Macro recorded by Zahid
'
'
Workbooks.OpenText Filename:= _
"C:\Documents and Settings\Zahid\My Documents\input.txt" _
, Origin:=437, StartRow:=1, DataType:=xlDelimited, TextQualifier:= _
xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, Semicolon:=False, _
Comma:=False, Space:=False, Other:=False, FieldInfo:=Array(1, 1), _
TrailingMinusNumbers:=True
Range("B1").Select
ActiveCell.FormulaR1C1 = "=RC[-1]&"" london"""
Range("B1").Select
Selection.AutoFill Destination:=Range("B1:B3")
Range("B1:B3").Select
Columns("B:B").Select
Selection.Copy
Workbooks.Add
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
ActiveWorkbook.SaveAs Filename:= _
"C:\Documents and Settings\Zahid\My Documents\output.txt", FileFormat:=xlUnicodeText _
, CreateBackup:=False
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!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|