Solved

Word Macro

Posted on 2002-06-17
6
193 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
Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Windows 10 start screen issues 9 55
How to Add / Edit Windows Menu 4 68
How to read File Date Created using VB6 8 52
Problem to line 23 54
Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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…

828 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