Consulting

Results 1 to 3 of 3

Thread: add text after second word after fullfill condition

  1. #1
    VBAX Regular
    Joined
    Jan 2018
    Posts
    48
    Location

    add text after second word after fullfill condition

    Hi, I need a code which add text after second word after fullfill condition but the syntax: oPara.Font.Size = 9 is not working, please, write me correct



    Sub add_after_xml()
    
    
                  Dim oPara As Paragraph
        For Each oPara In ActiveDocument.Paragraphs
                
    If Len(oPara.Range.Text) > 1 And oPara.Font.Size = 9 Then 
        With oPara.Range.Words(2)
                    .InsertAfter "</Bold:bb>"
                    .Collapse 0
        End With
    
    
    End If
    
    
            
        Next oPara
    End Sub
    Cheers
    Karol

  2. #2
    Microsoft Word MVP 2003-2009 VBAX Guru gmaxey's Avatar
    Joined
    Sep 2005
    Posts
    2,906
    Location
    If Len(oPara.Range.Text) > 1 And oPara.Range.Font.Size = 9 Then
    Greg

    Visit my website: http://gregmaxey.com

  3. #3
    VBAX Regular
    Joined
    Jan 2018
    Posts
    48
    Location
    Ok, it works, but only when paragraph include only two words, My goal is to insert text before and after bold is end. So above code is completely wrong.


    Here is example what should it do:
    "<Bold:bb>Lorem ipsum </Bold:bb> dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
    <Bold:bb>Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. </Bold:bb>
    <Bold:bb>Duis aute irure dolor in reprehenderit in voluptate velit esse </Bold:bb>cillum dolore eu fugiat nulla pariatur.
    Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."


    I have no idea how to handle it.
    Last edited by dagerr; 11-16-2018 at 05:12 AM.
    Karol

Posting Permissions

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