Selecting Text lines using VBA

L

Lumpy

I am using a VBA Script running in Excel to format my wod Document,
have a few Questions,

1.) Can I select specific text?
2.) is there any way to insert text in two different columns on th
same line
3.) How can I select text for a hard pagebreak?

Any insights would be greatly appreciate
 
D

Doug Robbins - Word MVP - DELETE UPPERCASE CHARACT

Hi Lumpy,

You will be better off to work with the .Range object than to actually
select text. If you can define a range that includes the text that you want
however, you can use [rangeobject].Select.

As far as the two different columns on the same line, do you mean two cells
of a table that are on the same row? If so, use the .Range of the Cells

ActiveDocument.Tables(1).Cell([rownum], [colnum]).Range.InsertBefore ["your
text"]

Once again, for the pagebreak, use the .Range object

This example inserts a page break immediately following the second
paragraph in the active document.

Set myRange = ActiveDocument.Paragraphs(2).Range
With myRange
.Collapse Direction:=wdCollapseEnd
.InsertBreak Type:=wdPageBreak
End With

Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested. Unsolicited questions forwarded
directly to me will only be answered on a paid consulting basis.
Hope this helps
Doug Robbins - Word MVP
 

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