Solved

Word Macro

Posted on 2002-06-17
6
192 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
Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

 
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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
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…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

778 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