Move to end of tab

S

sharonm

Hello,

I am new to using VBA in Word. I have a document with multiple lines of data
formatted something like the following: (4 sections and each are at a tab
position)

000018 123 Spring Road Kokomo, IN 46901 LANDLORD

I want to be able to move to the 1st section, copy it, and then paste it
into Excel, but I am not sure how you would navigate through the data in
Word. I think I want to use the Selection.MoveEnd but I am not sure what the
complete command would be. Or would I use something different?

Any help would be greatly appreciated. Thanks in advance.
 
G

Greg Maxey

Assuming that each line is a separate paragraph then something like this
might work:

Sub ScratchMacro()
Dim oPar As Paragraph
Dim oRng As Word.Range
For Each oPar In ActiveDocument.Range.Paragraphs
Set oRng = oPar.Range
oRng.Collapse wdCollapseStart
oRng.MoveEndUntil Chr(9)
'Paste oRng into Exel
Next oPar
Set oRng = Nothing
End Sub
 

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