[RESOLVED] Problem with paste text on right location.-VBForums
Results 1 to 3 of 3

Thread: [RESOLVED] Problem with paste text on right location.

  1. #1

    Thread Starter
    Lively Member elmnas's Avatar
    Join Date
    Jul 2009
    Posts
    127

    Resolved [RESOLVED] Problem with paste text on right location.

    Hello guys,

    I got a problem...

    How do I paste the text between,
    the 2 linebreaks,
    I googled some but I am not so familiar with "selection.paste"

    Please help me out


    see the picture
    Name:  test.jpg
Views: 156
Size:  6.0 KB


    Here is the code (see below)

    Sub test()
    '
    ' test
    '
    '

    Dim oRng As Word.Range
    Set oRng = ActiveDocument.Range
    With oRng.Find
    .Text = "Claims"
    .Font.Name = "Arial"
    .Font.Bold = True
    Do While .Execute
    oRng.MoveEndUntil Chr(11)
    oRng.MoveEnd wdCharacter, 1
    oRng.MoveEndUntil Chr(11)
    oRng.HighlightColorIndex = wdBrightGreen
    oRng.Collapse wdCollapseEnd
    Loop
    End With


    Dim thisdoc As Document
    Dim Str
    Set thisdoc = ActiveDocument
    Dim targDoc As Word.Document
    Set targDoc = Application.Documents.Open("G:\patent\NewEuropat.dot")
    Documents(thisdoc).Activate

    For Each Str In ActiveDocument.StoryRanges
    Str.Find.ClearFormatting
    Str.Find.Text = ""
    Str.Find.Highlight = True

    While Str.Find.Execute
    Str.Copy
    Documents(targDoc).Activate



    ' Here------------------------
    Selection.Paste

    ' Here-----------------------


    Documents(thisdoc).Activate

    Wend
    Next

    With cleanform
    Documents(targDoc).Activate
    Selection.WholeStory
    Options.DefaultHighlightColorIndex = wdNoHighlight
    Selection.Range.HighlightColorIndex = wdNoHighlight
    Selection.Font.Bold = wdToggle
    Selection.Font.Name = "Times New Roman"
    Selection.Font.Size = 12
    End With

    End Sub


    Please help a newb out


    Thank you in advance,

  2. #2
    Junior Member
    Join Date
    Jun 2014
    Posts
    16

    Re: Problem with paste text on right location.

    Could you try:

    L = line you specify

    Range(L,L).Select
    Activedocument.paste

    instead of Selection.Paste?
    Last edited by Arithos; Jul 4th, 2014 at 09:19 AM.

  3. #3

    Thread Starter
    Lively Member elmnas's Avatar
    Join Date
    Jul 2009
    Posts
    127

    Re: Problem with paste text on right location.

    Quote Originally Posted by Arithos View Post
    Could you try:

    L = line you specify

    Range(L,L).Select
    Activedocument.paste

    instead of Selection.Paste?

    well thank you

    I used


    first


    While Str.Find.Execute
    Str.Copy
    Documents(targDoc).Activate
    Selection.MoveRight Unit:=wdCharacter, Count:=50
    Selection.MoveDown Unit:=wdLine, Count:=1
    Selection.Paste
    Documents(thisdoc).Activate
    Wend
    Next



    and then this to search for empty linebreaks


    With Selection.Find
    .Text = "^p^p"
    .Replacement.Text = "^p"
    .Execute Replace:=wdReplaceAll, Forward:=True, _
    Wrap:=wdFindContinue
    End With

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.