Solved

Word Macro

Posted on 2002-06-17
6
195 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

 
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

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

724 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