Select from insertion point to text string, and then do it all over again

B

baldwin_kevin

I am creating 850 static HTML Web pages by using Mail Merge in
Microsoft Word. (The static Web pages are then compiled into one
metafile.) After I merge the Web page data into Word, I have one, long
document that is separated by 850 section marks.

I have VBA code that allows me to cut a selection from the one, long
document and to paste the selection into individual .htm files. I have
not figured out, however, how to define the 850 separate selections in
the one, long document. I also need help returning to the one, long
document and moving the the next section in it.

Specifically, I need VBA code to do the following things:

1. To use the current insertion point as the beginning of the
selection or range.
2. To extend the selection or range so that it includes everything up
to the next occurrence of the text string "</html>".
3. To call the cut-and-paste VBA sub that I already have. (This VBA
sub creates, saves, and closes the individual file.)
4. To return to the one, long document as the ActiveDocument.
5. To move the insertion point to the beginning of the next section.
6. To repeat this action as long as another "</html>" text string
exists in the one, long document.

Thank you,
--K
 
H

Helmut Weber

Hi Kevin...
too many questions at once.

1st, you don't have to cut and paste.
Just set the range of e.g. doc2 to a range of doc1.
There are lots of examples here.

2nd, don't use activedocument.
Define Doc1 and Doc2 and use these objects.

How to get a range from the insertion point
to a string including that string.

Sub Test3389()
Dim rTmp As Range
Set rTmp = Selection.Range
Dim a As Long ' range start
Dim z As Long ' range end
a = rTmp.Start
ResetSearch ' recommended
With rTmp.Find
.Text = "</html>"
.Wrap = wdFindStop
If .Execute Then
z = rTmp.End
rTmp.Start = a
rTmp.Select ' for testing
End If
End With
ResetSearch ' recommended
End Sub

Read
http://word.mvps.org/faqs/macrosvba/GetIndexNoOfPara.htm
zu get to the next section.

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

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