Repeat to End

R

Robert

I'm a newbie at this so please bear with me.
I have a simple macro that deletes the 1st few characters
of a line based on the position of the second text object.
I just need it to repeat to the end of the file.

This is what I have

Sub StripPoints()
'
' StripPoints Macro

Selection.HomeKey Unit:=wdLine
Selection.MoveRight Unit:=wdWord, Count:=2, Extend:=wdExtend
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.MoveDown Unit:=wdLine, Count:=1
End Sub

Suggestions?
Or perhaps a good web site for beginners?

TIA

Robert
 
H

Helmut Weber

Hi Robert,

if your text looks like:

Test test test akdjkaakjd¶
Test test test akdjkaakjd¶
Test test test akdjkaakjd¶

Then you are talking about paragraphs, not lines,
though the paragraphs consist of only one line.
I have a simple macro that deletes the 1st few characters
of a line based on the position of the second text object.

You have to explain, what you mean by a text-object.

Why is your macro called "StripPoints"?

There is a beginners group, too.
microsoft.public.word.vba.beginners

See in addition:

http://word.mvps.org/faqs/macrosvba/VBABasicsIn15Mins.htm
 
R

Robert

Here is a sample line from the asci file i'm working with,

2023, 6+50.00,827.366,812.360,-15.006

All I need to do is delete the 2023,

No problem. I just want it to continue
to the end of the file. I normally use textpad for
stuff like this. But I want to make it so it can be done
in word. I'm just a newbie to using word to perform
macros.

There are several other functions I need to do that I can figure out,
I just need a direction on creating the process for it to continue to the
end of the file.

TIA

Robert
 
H

Helmut Weber

Hi Robert,

With ActiveDocument.Range
MsgBox .ComputeStatistics(wdStatisticLines)
MsgBox .Paragraphs.Count
End With

If the first message is the same as the second,
then your doc consists of one-lineparagraphs,
and you could use something like this:

Sub test98766()
Dim oPrg As Paragraph
For Each oPrg In ActiveDocument.Range.Paragraphs
oPrg.Range.Select
Selection.Collapse
Selection.MoveRight Unit:=wdWord, _
Count:=2, Extend:=wdExtend
Selection.Delete Unit:=wdCharacter, Count:=1
' no moving down necessary
Next
End Sub

Which isn't the most professional approach,
but if it is working for you, who cares.

Greetings from Bavaria, Germany
Helmut Weber, MVP WordVBA
"red.sys" & chr(64) & "t-online.de"
Word 2002, Windows 2000 (german versions)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top