From: Doug Robbins - Word MVP on
Declare pavadinimas as a Range, then use

Set pavadinimas = Source.Paragraphs.First.Range
pavadiminas.End = pavadinimas.End - 1


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

"VBA" <VBA(a)discussions.microsoft.com> wrote in message
news:F9F47188-171C-491B-A046-44571885FDD8(a)microsoft.com...
> Pavadinimas contains first line after page break, I want that don't copy
> to
> pavadinimas enter symbol.so could you tell me what i need to change in
> macro?
>
>
> "Doug Robbins - Word MVP" wrote:
>
>> And what does pavadinimas contain at that point?
>>
>> --
>> Hope this helps.
>>
>> Please reply to the newsgroup unless you wish to avail yourself of my
>> services on a paid consulting basis.
>>
>> Doug Robbins - Word MVP
>>
>> "VBA" <VBA(a)discussions.microsoft.com> wrote in message
>> news:D35E8404-578F-4A1F-8D62-E458554B2332(a)microsoft.com...
>> > When I click on Debug the line is highlighted Targer.SaveAs
>> > fileName:=pavadinimas
>> >
>> >
>> > Arnoldas Rope
>> >
>> >
>> >
>> > "Doug Robbins - Word MVP" wrote:
>> >
>> >> I would rewrite the code as follows:
>> >>
>> >> Sub SplitDoc()
>> >>
>> >> Dim rng As Range
>> >> Dim c As Long
>> >> Dim i As Integer
>> >> Dim pavadinimas As String
>> >> Dim Show As Boolean
>> >> Dim Source as Document, Target as Document
>> >>
>> >> Set Source = ActiveDocument
>> >>
>> >> Show = Source.ActiveWindow.View.ShowHiddenText
>> >> If Not Show Then Source.ActiveWindow.View.ShowHiddenText = True
>> >> pavadinimas = Source.Paragraphs.First.Range.Text
>> >>
>> >> Set rng = Source.Range
>> >> rng.Collapse wdCollapseStart
>> >> Do
>> >> c = rng.MoveEndUntil(Chr$(12), wdForward)
>> >> If c = 0 Then
>> >> rng.End = Source.Range.End
>> >> Else
>> >> If rng.Paragraphs.First.Range.Characters.First = Chr$(12) Then
>> >> pavadinimas = Mid$(rng.Paragraphs.First.Range.Text, 2)
>> >> Else
>> >> pavadinimas = rng.Paragraphs.First.Range.Text
>> >> End If
>> >>
>> >> rng.Start = rng.MoveStartUntil(Chr$(13), wdForward)
>> >> rng.Copy
>> >> Set Target = Documents.Add
>> >> Target.Range.Paste
>> >> i = i + 1
>> >> Target.SaveAs fileName:=pavadinimas
>> >> Target.Close
>> >> rng.MoveEnd wdCharacter, 1
>> >> rng.Collapse wdCollapseEnd
>> >> End If
>> >> Loop Until c = 0
>> >> Source.ActiveWindow.View.ShowHiddenText = Show
>> >> End Sub
>> >>
>> >> Your problem could be the system losing track of the ActiveDocument,
>> >> which
>> >> the above modification will prevent.
>> >>
>> >> If not, what line of code is highlighted if you click on Debug.
>> >>
>> >>
>> >> --
>> >> Hope this helps.
>> >>
>> >> Please reply to the newsgroup unless you wish to avail yourself of my
>> >> services on a paid consulting basis.
>> >>
>> >> Doug Robbins - Word MVP
>>
>>
>>