Solved

Word Macro

Posted on 2002-06-17
6
194 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to debug this code 7 65
vb6 connector to mongodb 2 141
SLMGR Switches Are Not Working On KMS Host 3 144
MS Access 03, TransferText, decimal places 8 85
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 trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
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…

733 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