Thanks again, Paul. I've gotten myself all tied up on page numbering.
In this bit of code:
Code:
p = Split(.Cell(r, 1).Range.Text, vbCr)(0) + 6: StrKey = ""
If p = 6 Then Exit For
Set Rng = DocRef.GoTo(What:=wdGoToPage, Name:=p).GoTo(What:=wdGoToBookmark, Name:="\page")
DocTgt.Range.Characters.Last.FormattedText = Rng.FormattedText
... adding 6 gets a song 6 further on. This is because of "Name:=p" gets the page with that number in the Header. Adding 6 on was for when I was using "Count:=p". If I remove the "+6" it gets the correctly numbered page, unless the p is 1, 2, 3 or 4, in which case it returns the first four physical pages, which do not have page numbers in their header (being the cover, 2 index pages and a notes page. The first song (page 1) is on the 5th physical page of the document.
If instead I use "Count:=p", I do need to add 6 to get the correct song. I found it was 6 through trial and error, as the first song is on the 5th physical page so adding 6 should get page 7, but it gets the 5th.
This works apart from the first song. Whatever p number is first in the list, the command returns the whole of the source document from that song onwards. So if I have 1, 2, 3 in my list, I get songs 1-138, then song 2, then song 3.
In summary, if I use "Name:=p" (without the +6) I can't retrieve the first 4 songs by number.
If I use "Count:=p" (with +6) I get the rest of the song book from that first listed page on, followed by the correct songs.
Incidentally, the end of list detection throws up an error - presumably because we can't use Split on an empty cell? I got round this be testing for len=2 as the next empty table cell will just contain Cr & Lf.
Your continued help is greatly appreciated.
Jeremy