Solved

Word Macro

Posted on 2002-06-17
6
189 Views
Last Modified: 2010-05-02
Hi,

I hope I'm asking this in the right place but...


How do I create a macro in MS Word to add Text.Write(" to the beginning and "); to the end of each line within my document?

Thanks in advance.
0
Comment
Question by:KAbbott
  • 3
  • 2
6 Comments
 
LVL 5

Expert Comment

by:rpai
ID: 7084050
do you mean manually create a macro?
0
 
LVL 8

Expert Comment

by:jessnjeff
ID: 7084084
...or are you asking for the code?
0
 
LVL 2

Author Comment

by:KAbbott
ID: 7086286
How do I create a macro from within Word (e.g. Tools->Macro->Visual Basic Editor.)

How's it done?
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 2

Author Comment

by:KAbbott
ID: 7086781
Hi,

I've managed to create a macro of the first line in my document of what I want to do:

Sub MyFileWrite()
'
' MyFileWrite Macro
' Macro recorded 18/06/02 by Kevin Abbott
'
    Selection.TypeText Text:="MyFile.Write("""
    Selection.EndKey Unit:=wdLine
    Selection.TypeText Text:=""");"
End Sub

How do I loop the above code so that it does this through-out the document which it is run on?

Thanks in advance.

0
 
LVL 2

Author Comment

by:KAbbott
ID: 7086791
Sorry,

Should of said that the above has to be repeated on every line of the current document
0
 
LVL 5

Accepted Solution

by:
rpai earned 50 total points
ID: 7089018
Sub MyFileWrite()
'
' MyFileWrite Macro
' Macro recorded 18/06/02 by Kevin Abbott
'
'-- Assuming there are 100 lines in  the document.
Dim iLoop as Integer
For iLoop = 0 to 100
   Selection.TypeText Text:="MyFile.Write("""
   Selection.EndKey Unit:=wdLine
   Selection.TypeText Text:=""");"
Next
End Sub
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now