justagrunt
Tue Apr 17 23:08:12 CDT 2007
Hi Helut,
Slight technical problem.
If I follow the example and use the following, dim's not shown but code
compiles OK,
If Dir(strCom) = "" Then
MsgBox "File does not exist"
Else
Set srcDoc = Wordapp.Documents.Open(strCom) 'attachment sheet
End If
'open the letter
Set destdoc7 = Wordapp.Documents.Open(strInputFileName) 'letter
Set bmrange = destdoc7.Bookmarks("section7").Range
bmrange.Text = srcDoc.Range.Text
destdoc7.Bookmarks.Add "section7", bmrange
destdoc7.Bookmarks("section7").Range.InsertBreak Type:=wdPageBreak
destdoc7.close (wdSaveChanges)
Rem With destdoc7
Rem.Bookmarks("section7").Range.FormattedText = srcDoc.Range.FormattedText
Rem .close (wdSaveChanges)
Rem End With
'close the Attachment sheet
srcDoc.close (wdDoNotSaveChanges)
Else
'do nothing
End If
I get a section break and no bookmark (section7),no text and enclosing
bookmarks either side.
Changing the formattedtext for text did made no difference.
I've run it thru 4 other sections and get the same result, section breaks,
no text
your welcome advice is appreciated.
--
Best Regards
Bill
"Helmut Weber" wrote:
> Hi,
>
> I'm assuming, you are talking about including [bookmarks].
>
> If you insert text at an including bookmark,
> the bookmark vanishes.
>
> See:
http://word.mvps.org/faqs/macrosvba/InsertingTextAtBookmark.htm
>
> So, if you follow the instructions,
> the bookmark is there again, but spans the inserted text.
>
> You may now serach the range of the newly created bookmark
> for the first period and insert a pagebreak after it.
>
> Still a stab in the dark.
>
> Sub Test4561()
> Dim rDcm As Range
> Dim rTmp As Range
> Set rDcm = ActiveDocument.Range
> Set rTmp = rDcm.Bookmarks("Lastname").Range
> rTmp.Text = "yyyyyy.yyyyyy"
> rTmp.Bookmarks.Add "Lastname", rTmp
> With rTmp.Find
> .Text = "."
> If .Execute Then
> rTmp.InsertAfter Chr(12)
> End If
> End With
> End Sub
>
> HTH
>
> --
> Greetings from Bavaria, Germany
>
> Helmut Weber, MVP WordVBA
>
> Win XP, Office 2003
> "red.sys" & Chr$(64) & "t-online.de"
>