kerrypnx
8/22/2018 - 9:35 AM

xml macro updata

revise 8-22

Sub run_old()

' Before run it you have to import all styles in, like in the ppt.
        
       
        Call change_layout
        
        Call import_style
        
        Call change_style_sort
        
        Call ctrl_shft_F9
        
        Call del_break_w2h
        
        Call del_soft_return
        
        Call del_blank_paragraph
      
        Call del_start
        
        Call del_notes
              
        Call del_all_bookmarks
        
        Call article_type
        
        Call article_title
        
        Call authors
        
        Call affiliations
        
        Call correspondence
        
        Call academic_editors
        
        Call publication_history
        
        Call abstract
        
        Call keywords
        
        Call jel_classifications
        
        Call del_blank_paragraph
        
        Call paragraph
        
        Call heading_1
        
        Call heading_2
        
        Call heading_3
        
        Call figure_caption
        
        Call figure_body
       
        'Call find_symbols
        
        Call scheme_caption
        
        Call scheme_body
        
        Call chart_caption
        
        Call chart_body
        
        
        Call table_caption
        
        'Call select_parts_apart_from_references
                
        'Call replace_spaces_to_no_styles
        
        Call figures_highlight
        
        Call figure_citation
        
        Call schemes_highlight
        
        Call scheme_citation
        
        Call charts_highlight
        
        Call chart_citation
        
        Call tables_highlight
        
        Call table_citation
        
        Call boxes_highlight
        
        Call box_citation
        
        Call sections_highlight
        
        Call section_citation
        
        Call number_citation
        
        Call Appendix_citation
        
        Call Supplementary_citation
        
        Call Appendices_highlight
        
        Call Appendixes_highlight
        
        Call conflicts_of_interest
        
        Call author_contributions
        
        Call acknowledgements
        
        Call references
       
        
        
       
      
        ' return the top
        Selection.HomeKey UNIT:=wdStory
        
End Sub
Sub run_new()

        Dim sty As Style
        Dim tureF As Boolean
        Dim userName As String
        Dim norName, currName As String
        
        tureF = True
        
        If Selection.LanguageID <> wdSimplifiedChinese Then
        
          For Each sty In ActiveDocument.Styles
         
            If sty.NameLocal = "MDPI_4.2_table_body" Then '如果原稿表格给的是左对齐,那么里面的加粗可能会丢失
            
                  ActiveDocument.Styles("MDPI_4.2_table_body").NameLocal = "_5_table_body"
                            
                  With ActiveDocument.Styles("_5_table_body")
                    .Font.name = "times new roman"
                    .Font.Size = 11
                  End With
                  
                  tureF = False
                  
                  Exit For
            End If
 
          Next
        End If
             
        Call change_layout
                
        Call import_style
        

        Call change_style_sort
        
        Call ctrl_shft_F9
        
        Call del_break_w2h
        
        Call del_column_break_w2h
        
        Call del_soft_return
        
        Call del_blank_paragraph
                            
        Call del_all_bookmarks
        
        Call set_text_kr
        
       
        Call article_type
        
        Call article_title
        
        Call authors
        
        Call affiliations
        
        Call correspondence_new
        
        Call special_notes
        
        Call academic_editors
        
        Call publication_history_2
        
        Call simple_summary
        
        Call featured_application
        
        Call abstract
        
        Call keywords
        
        Call pacs
        
        Call msc
        
        Call jel_classification
        
        Call key_contribution
                
        
        
        
        Call del_blank_paragraph
        
        'Call paragraph
        
        
        Call heading_1
        
        Call heading_2
        
        Call heading_3
        
        Call figure_caption
        
        Call figure_body
       
        'Call find_symbols
        
        Call scheme_caption
        
        Call scheme_body
        
        Call chart_caption
        
        Call chart_body
        
        Call table_caption
        
        'Call select_parts_apart_from_references
                
        'Call replace_spaces_to_no_styles
        
        Call figures_highlight
        
        Call figure_citation
        
        Call schemes_highlight
        
        Call scheme_citation
        
        Call charts_highlight
        
        Call chart_citation
        
        Call tables_highlight
        
        Call table_citation
        
        Call boxes_highlight
        
        Call box_citation
        
        Call number_citation
        
        Call sections_highlight
        
        Call section_citation
        
        Call Appendix_citation
        
        Call Supplementary_citation
        
        Call Appendices_highlight
        
        Call Appendixes_highlight
        
        Call replace_ack
        
        Call supplementary_materials
        
        Call conflicts_of_interest
                
        Call author_contributions
        Call Funding
        
        Call acknowledgements
        
        Call appendix
        
        Call references
        
        
        
        Call del_oShape
        
        Call del_notes
        
        Call set_table_body
      
        Call sample_availability
        
        ' return the top
        Selection.HomeKey UNIT:=wdStory
        
End Sub
Sub Funding()
' make acknowledgements as 1st level
    With Selection.Find
        .Text = "Funding^13"
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        .Format = False
        .MatchCase = False
        .MatchWholeWord = False
        .MatchByte = True
        .MatchWildcards = True
        .MatchSoundsLike = False
        .MatchAllWordForms = False
        .Execute
        If .Found And Asc(Selection.Range.Previous) = 13 Then
            Selection.HomeKey UNIT:=wdLine
            Selection.Style = ActiveDocument.Styles("_4_heading_1")
            Selection.MoveDown UNIT:=wdParagraph, count:=1
        End If
    End With
    
End Sub
Sub author_year()
 With Selection.Find
        .ClearFormatting
        .Replacement.ClearFormatting
        .Replacement.Style = ActiveDocument.Styles("_4_text_citation")
        .Text = "(\([!0-9\(\)][!\(\)]@[0-9]{4}\))"
        .Replacement.Text = "\1"
        .Forward = True
        .Wrap = wdFindContinue
        .Format = True
        .MatchCase = False
        .MatchWholeWord = False
        .MatchByte = False
        .MatchAllWordForms = False
        .MatchSoundsLike = False
        .MatchWildcards = True
        .Execute Replace:=wdReplaceAll
    End With
    With Selection.Find
        .ClearFormatting
        .Replacement.ClearFormatting
        .Replacement.Style = ActiveDocument.Styles("_4_text_citation")
        .Text = "(\([!0-9\(\)][!\(\)]@[0-9]{4}[!\)]{1,}\))"
        .Replacement.Text = "\1"
        .Forward = True
        .Wrap = wdFindContinue
        .Format = True
        .MatchCase = False
        .MatchWholeWord = False
        .MatchByte = False
        .MatchAllWordForms = False
        .MatchSoundsLike = False
        .MatchWildcards = True
        .Execute Replace:=wdReplaceAll
    End With
End Sub
Sub change_web_layout()
        
        Call change_layout
        
        Call import_style
        
        Call change_style_sort

End Sub
Sub ref_citation()
        
        Call ctrl_shft_F9
        
        Call year_highlight
        
        Call forthcoming_highlight
        
        Call n_d_highlight
        
        Call author_year

End Sub
Sub year_highlight()

    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    Selection.Find.Replacement.Font.Color = wdColorRed
    With Selection.Find
        .Text = "\([1-9][0-9][0-9][0-9]"
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        .Format = True
        .MatchCase = True
        .MatchWholeWord = False
        .MatchByte = False
        .MatchWildcards = True
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
        
End Sub


Sub final_run()
' called when almost finished
        Call del_blank_paragraph
        Call del_soft_return
        Call del_all_bookmarks
        Call del_blank_paragraph
        Call table_citation
        Call figure_citation
        Call box_citation
        Call scheme_citation
        Call number_citation
        Call section_citation
        Call chart_citation
        Call Appendix_citation
        Call Supplementary_citation
        
End Sub


Sub change_layout()
' so that you could see pure content
    ActiveWindow.View.Type = wdWebView
End Sub

Sub change_style_sort()
    ActiveDocument.FormattingShowFont = False
    ActiveDocument.FormattingShowParagraph = False
    ActiveDocument.FormattingShowNumbering = False
    ActiveDocument.StyleSortMethod = wdStyleSortByName
End Sub


Sub ctrl_shft_F9()
' unlink the whole field
    Selection.WholeStory
    Selection.Fields.unlink
    Selection.HomeKey UNIT:=wdStory
End Sub



Sub del_break_w2h()
' delete page and section breaks
    With ActiveDocument.Content.Find
        .ClearFormatting
        .MatchWildcards = True
        .Text = "^m"
        .Replacement.Text = "^p"
        .Execute Replace:=wdReplaceAll
    End With
End Sub
Sub del_column_break_w2h()
' delete page and section breaks
    With ActiveDocument.Content.Find
        .ClearFormatting
        .MatchWildcards = True
        .Text = "^n"
        .Replacement.Text = "^p"
        .Execute Replace:=wdReplaceAll
    End With
End Sub

Sub del_soft_return()
' delete soft return
    With ActiveDocument.Content.Find
        .ClearFormatting
        .MatchWildcards = True
        .Text = "^l"
        .Replacement.Text = ""
        .Execute Replace:=wdReplaceAll
    End With
End Sub

Sub del_blank_paragraph()
' delete duplicate blank lines
    With ActiveDocument.Content.Find
        .ClearFormatting
        .MatchWildcards = False
        .Text = "^p^p"
        .Replacement.Text = "^p"
        .Execute Replace:=wdReplaceAll
    End With
End Sub

Sub del_all_bookmarks()
' delete all bookmarks
       Do Until ActiveDocument.Bookmarks.count = 0:
    ActiveDocument.Bookmarks(1).Delete: Loop

End Sub
Sub del_oShape()
  For Each oShapeRange In ActiveDocument.Shapes
    oShapeRange.Delete
    Next oShapeRange
  
End Sub
Sub del_start()
    Selection.Find.ClearFormatting
    With Selection.Find
        .Text = "www.mdpi.com/journal/"
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        .Format = False
        .MatchCase = False
        .MatchWholeWord = False
        .MatchByte = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Find.Execute
    Selection.EndKey UNIT:=wdLine
    Selection.HomeKey UNIT:=wdStory, Extend:=wdExtend
    Selection.Delete
    Selection.MoveRight UNIT:=wdCharacter, count:=1
    Selection.TypeBackspace
End Sub

Sub del_notes()
' delete final license note, since Merrin will add them in
    With ActiveDocument.Content.Find
        .ClearFormatting
        .MatchWildcards = True
        .Text = "^13?^32[0-9][0-9][0-9][0-9] by the authors*^13"
        .Replacement.Text = ""
        .Execute Replace:=wdReplaceAll
    End With
End Sub

Sub article_type()
' make whatever written in 1st line as "Review", as Merrin could only recogonize "Review"...
        Selection.EndKey UNIT:=wdLine, Extend:=wdExtend
        Selection.Style = ActiveDocument.Styles("_1_article_type")
End Sub

Sub article_title()
' apply style on article title
        Selection.MoveDown UNIT:=wdLine, count:=1
        Selection.Style = ActiveDocument.Styles("_1_article_title")
        'Selection.MoveEnd Unit:=wdLine, Count:=1
End Sub

Sub authors()
' seperate different authors' names and apply style on them
    Selection.MoveDown UNIT:=wdParagraph, count:=1
    Selection.Style = ActiveDocument.Styles("_2_author_name")
    Selection.MoveDown UNIT:=wdParagraph, Extend:=wdExtend
    With Selection.Find
        .ClearFormatting
        .Text = " and "
        .Wrap = wdFindStop
        .Replacement.ClearFormatting
        .Replacement.Text = ", "
        .Execute Replace:=wdReplaceAll
        .Text = ", "
        .Replacement.Text = "^p"
        .Forward = True
        .Format = False
        .MatchCase = False
        .MatchWholeWord = False
        .MatchByte = True
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
        .Execute Replace:=wdReplaceAll
    End With
End Sub
Sub affiliations()
' apply style on texts until find "*"
With ActiveDocument.Content.Find
     .ClearFormatting
    .Replacement.ClearFormatting
    .Text = "Received: "
    .Replacement.Text = "*Received: "
    .MatchWildcards = False
    .MatchCase = False
    .Execute Replace:=wdReplaceOne
    
    
   
End With
    Selection.MoveDown UNIT:=wdParagraph, Extend:=wdMove, count:=1
    Selection.MoveEndUntil Cset:="*", count:=wdForward
    Selection.Style = ActiveDocument.Styles("_2_author_affiliation")
    
    With ActiveDocument.Content.Find
     .ClearFormatting
    .Replacement.ClearFormatting
    .Text = "*Received: "
    .Replacement.Text = "Received: "
    .MatchWildcards = False
    .MatchCase = False
    .Execute Replace:=wdReplaceOne
    
    
   
End With
End Sub


Sub correspondence()
' apply style on correspondence
    With Selection.Find
        .Text = "to whom correspondence should be addressed"
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        .Format = False
        .MatchCase = False
        .MatchWholeWord = False
        .MatchByte = True
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
        .Execute
    End With
    Selection.HomeKey UNIT:=wdLine
    Selection.MoveDown UNIT:=wdParagraph, count:=1, Extend:=wdExtend
    Selection.Style = ActiveDocument.Styles("_2_author_correspondence")
    
End Sub

Sub correspondence_new()
' apply style on correspondence
    With Selection.Find
        .Text = "Correspondence:"
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        .Format = False
        .MatchCase = False
        .MatchWholeWord = False
        .MatchByte = True
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
         .Execute
        If .Found Then
        Selection.HomeKey UNIT:=wdLine
        Selection.MoveDown UNIT:=wdParagraph, count:=1, Extend:=wdExtend
        Selection.Style = ActiveDocument.Styles("_2_author_correspondence")
        End If
        End With
    'Selection.HomeKey unit:=wdLine
    'Selection.MoveDown unit:=wdParagraph, count:=1, Extend:=wdExtend
    'Selection.Style = ActiveDocument.Styles("_2_author_correspondence")
    
End Sub
Sub special_notes()
' apply style on correspondence
    With Selection.Find
        .Text = ChrW(8224)
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        .Format = False
        .MatchCase = False
        .MatchWholeWord = False
        .MatchByte = True
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
        .Execute
        If .Found Then
        Selection.MoveDown UNIT:=wdParagraph, count:=1, Extend:=wdExtend
        Selection.Style = ActiveDocument.Styles("_2_author_affiliation")
        End If
        End With
    'Selection.HomeKey unit:=wdLine
    'Selection.MoveDown unit:=wdParagraph, count:=1, Extend:=wdExtend
    'Selection.Style = ActiveDocument.Styles("_2_author_affiliation")
    
End Sub
Sub academic_editors()
' seperate different authors' names and apply style on them
    With Selection.Find
        .Text = "Academic Editor"
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        .Format = False
        .MatchCase = False
        .MatchWholeWord = False
        .MatchByte = True
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
        .Execute
        If .Found And Selection.Range.Previous.Text = ChrW(13) Then
        Selection.MoveDown UNIT:=wdParagraph, count:=1
        Selection.Style = ActiveDocument.Styles("_2_academic_editor")
        End If
    End With
    
'    selection.MoveDown unit:=wdParagraph, count:=1, Extend:=wdExtend
'    selection.Style = ActiveDocument.Styles("_2_academic_editor")
    Selection.Collapse wdCollapseEnd
End Sub
Sub publication_history()
' apply style on publication history
    With Selection.Find
        .Text = "Received:"
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        .Format = False
        .MatchCase = False
        .MatchWholeWord = False
        .MatchByte = True
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
        .Execute
    End With
    
    

End Sub
Sub publication_history_2()


    With Selection.Find
         
        .ClearFormatting
        .Text = "Received:"
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        .Forward = True
        .Format = False
        .MatchCase = False
        .MatchWholeWord = False
        .MatchByte = True
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
        .Execute
        If .Found Then
                  Selection.Paragraphs(1).Range.Style = ActiveDocument.Styles("_3_publication_history")

   
        End If
        End With
    
End Sub

Sub simple_summary()

    With Selection.Find
        .Text = "Simple Summary:"
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        .Format = False
        .MatchCase = False
        .MatchWholeWord = False
        .MatchByte = True
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
        .Execute
        If .Found Then
        Selection.MoveDown UNIT:=wdParagraph, count:=1, Extend:=wdExtend
        Selection.Style = ActiveDocument.Styles("_3_abstract")
        End If
    End With
    
'    selection.MoveDown unit:=wdParagraph, count:=1, Extend:=wdExtend
'    selection.Style = ActiveDocument.Styles("_3_abstract")
    
End Sub
Sub featured_application()

    With Selection.Find
        .Text = "Featured Application:"
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        .Format = False
        .MatchCase = False
        .MatchWholeWord = False
        .MatchByte = True
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
        .Execute
        If .Found Then
        Selection.MoveDown UNIT:=wdParagraph, count:=1, Extend:=wdExtend
        Selection.Style = ActiveDocument.Styles("_3_abstract")
        End If
    End With
    
'    selection.MoveDown unit:=wdParagraph, count:=1, Extend:=wdExtend
'    selection.Style = ActiveDocument.Styles("_3_abstract")
    
End Sub

Sub abstract()
' apply style on abstract, same as Yidong's
    With Selection.Find
        .Text = "Abstract:"
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        .Format = False
        .MatchCase = False
        .MatchWholeWord = False
        .MatchByte = True
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
        .Execute
        If .Found Then
        Selection.MoveDown UNIT:=wdParagraph, count:=1, Extend:=wdExtend
        Selection.Style = ActiveDocument.Styles("_3_abstract")
        End If
    End With
    'selection.MoveDown unit:=wdParagraph, count:=1, Extend:=wdExtend
    'selection.Style = ActiveDocument.Styles("_3_abstract")
       
End Sub

Sub keywords()
' apply style on keywords, same as Yidong's
    ' keywords
    With Selection.Find
        .Text = "Keywords:"
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        .Format = False
        .MatchCase = False
        .MatchWholeWord = False
        .MatchByte = True
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
        .Execute
        If .Found Then
        Selection.MoveDown UNIT:=wdParagraph, count:=1, Extend:=wdExtend
        
        Selection.Style = ActiveDocument.Styles("_3_keywords")
        End If
    End With
    'selection.MoveDown unit:=wdParagraph, count:=1
   ' selection.MoveDown unit:=wdParagraph, count:=1,
    'selection.Style = ActiveDocument.Styles("_3_keywords")
End Sub
Sub pacs()

    With Selection.Find
        .Text = "PACS:"
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        .Format = False
        .MatchCase = False
        .MatchWholeWord = False
        .MatchByte = True
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
        .Execute
        If .Found Then
        Selection.MoveDown UNIT:=wdParagraph, count:=1, Extend:=wdExtend
        Selection.Style = ActiveDocument.Styles("_3_classifications")
        End If
    End With
    'selection.MoveDown unit:=wdParagraph, count:=1
   ' selection.MoveDown unit:=wdParagraph, count:=1, Extend:=wdExtend
    'selection.Style = ActiveDocument.Styles("_3_classifications")
End Sub
Sub msc()

    With Selection.Find
        .Text = "MSC:"
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        .Format = False
        .MatchCase = False
        .MatchWholeWord = False
        .MatchByte = True
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
        .Execute
        If .Found Then
        Selection.MoveDown UNIT:=wdParagraph, count:=1, Extend:=wdExtend
        Selection.Style = ActiveDocument.Styles("_3_classifications")
        End If
    End With
    'selection.MoveDown unit:=wdParagraph, count:=1
   ' selection.MoveDown unit:=wdParagraph, count:=1, Extend:=wdExtend
    'selection.Style = ActiveDocument.Styles("_3_classifications")
End Sub
Sub jel_classification()

    With Selection.Find
        .Text = "JEL Classification:"
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        .Format = False
        .MatchCase = False
        .MatchWholeWord = False
        .MatchByte = True
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
        .Execute
        If .Found Then
        Selection.MoveDown UNIT:=wdParagraph, count:=1, Extend:=wdExtend
        Selection.Style = ActiveDocument.Styles("_3_classifications")
        End If
    End With
    'selection.MoveDown unit:=wdParagraph, count:=1
   ' selection.MoveDown unit:=wdParagraph, count:=1, Extend:=wdExtend
    'selection.Style = ActiveDocument.Styles("_3_classifications")
End Sub

Sub key_contribution()

    With Selection.Find
        .Text = "Key Contribution:"
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        .Format = False
        .MatchCase = False
        .MatchWholeWord = False
        .MatchByte = True
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
        .Execute
        If .Found Then
        Selection.MoveDown UNIT:=wdParagraph, count:=1, Extend:=wdExtend
        Selection.Style = ActiveDocument.Styles("_8_notes")
        End If
    End With
    'selection.MoveDown unit:=wdParagraph, count:=1
   ' selection.MoveDown unit:=wdParagraph, count:=1, Extend:=wdExtend
    'selection.Style = ActiveDocument.Styles("_8_notes")
End Sub

Sub jel_classifications()
 'seperate different authors' names and apply style on them
    Selection.MoveDown UNIT:=wdParagraph, count:=1
    Selection.MoveDown UNIT:=wdParagraph, count:=1, Extend:=wdExtend
    Selection.Style = ActiveDocument.Styles("_3_classifications")
End Sub
    
    

Sub paragraph()
' apply styles on all the rest of article body
    Selection.MoveDown UNIT:=wdParagraph, count:=1
    Selection.EndKey UNIT:=wdStory, Extend:=wdExtend
    'Selection.ClearFormatting
    Selection.Style = ActiveDocument.Styles("_4_text")
End Sub

Sub heading_1()
Selection.HomeKey wdStory
' apply styles on 1st level title based on number(1 or more digits) plus text then paragraph break
    With Selection.Find
        .ClearFormatting
        .Replacement.ClearFormatting
        
        .Text = "[0-9]{1,}. {1,}[A-Z]*^13"
       
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        '.Format = True
        .MatchCase = False
        .MatchWholeWord = False
        .MatchByte = False
        .MatchAllWordForms = False
        .MatchSoundsLike = False
        .MatchWildcards = True
        Do
        .Execute
        If .Found Then
        If Asc(Selection.Range.Previous) = 13 Then
        .Replacement.Style = ActiveDocument.Styles("_4_heading_1")
        .Execute Replace:=wdReplaceOne
        Selection.MoveRight wdCharacter, 1
        Else
        Selection.MoveRight wdCharacter, 1
        End If
        Else
         
        Exit Do
        End If
        Loop
    End With
    
   End Sub
   
Sub heading_2()
' apply styles on 2nd level title based on number(1 or more digits, 2 layers) plus text then paragraph break
    Selection.HomeKey wdStory

    With Selection.Find
        .ClearFormatting
        .Replacement.ClearFormatting
        
        .Text = "[0-9]{1,}.[0-9]{1,}. {1,}[A-Z]*^13"
       
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        '.Format = True
        .MatchCase = False
        .MatchWholeWord = False
        .MatchByte = False
        .MatchAllWordForms = False
        .MatchSoundsLike = False
        .MatchWildcards = True
        Do
        .Execute
        If .Found Then
        If Asc(Selection.Range.Previous) = 13 Then
        .Replacement.Style = ActiveDocument.Styles("_4_heading_2")
        .Execute Replace:=wdReplaceOne
        Selection.MoveRight wdCharacter, 1
        Else
        Selection.MoveRight wdCharacter, 1
        End If
        Else
         
        Exit Do
        End If
        Loop
    End With
    
    'With Selection.Find
       ' .ClearFormatting
       ' .Replacement.ClearFormatting
       ' .Replacement.Style = ActiveDocument.Styles("_4_heading_2")
       ' .Text = "[0-9]{1,}.[0-9]{1,}. {1,}[A-Z]*^13"
       '
      '  .Replacement.Text = ""
       ' .Forward = True
       ' .Wrap = wdFindContinue
      '  '.Format = True
      '  .MatchCase = False
      '  .MatchWholeWord = False
      '  .MatchByte = False
      '  .MatchAllWordForms = False
     '   .MatchSoundsLike = False
     '   .MatchWildcards = True
     '   .Execute Replace:=wdReplaceAll
   ' End With
    End Sub
    
    Sub heading_3()
' apply styles on 2nd level title based on number(1 or more digits, 3 layers) plus text then paragraph break
    Selection.HomeKey wdStory

    With Selection.Find
        .ClearFormatting
        .Replacement.ClearFormatting
        
        .Text = "[0-9]{1,}.[0-9]{1,}.[0-9]{1,}. {1,}[A-Z]*^13"
       
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        '.Format = True
        .MatchCase = False
        .MatchWholeWord = False
        .MatchByte = False
        .MatchAllWordForms = False
        .MatchSoundsLike = False
        .MatchWildcards = True
        Do
        .Execute
        If .Found Then
        If Asc(Selection.Range.Previous) = 13 Then
        .Replacement.Style = ActiveDocument.Styles("_4_heading_3")
        .Execute Replace:=wdReplaceOne
        Selection.MoveRight wdCharacter, 1
        Else
        Selection.MoveRight wdCharacter, 1
        End If
        Else
         
        Exit Do
        End If
        Loop
    End With
    
   ' With Selection.Find
       ' .ClearFormatting
       ' .Replacement.ClearFormatting
      '  .Replacement.Style = ActiveDocument.Styles("_4_heading_3")
      '  .Text = "[0-9]{1,}.[0-9]{1,}.[0-9]{1,}. {1,}[A-Z]*^13"
       ' .Replacement.Text = ""
       ' .Forward = True
      '  .Wrap = wdFindContinue
        '.Format = True
      '  .MatchCase = False
      '  .MatchWholeWord = False
      '  .MatchByte = False
      '  .MatchAllWordForms = False
      '  .MatchSoundsLike = False
      '  .MatchWildcards = True
      '  .Execute Replace:=wdReplaceAll
    'End With
    End Sub
    
Sub figure_caption()
' apply style on figure caption
    Selection.HomeKey wdStory

    With Selection.Find
        .ClearFormatting
        .Replacement.ClearFormatting
        
        .Text = "Figure [0-9]{1,}. "
       
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        '.Format = True
        .MatchCase = False
        .MatchWholeWord = False
        .MatchByte = False
        .MatchAllWordForms = False
        .MatchSoundsLike = False
        .MatchWildcards = True
        Do
        .Execute
        If .Found Then
        If Asc(Selection.Range.Previous) = 13 Then
        .Replacement.Style = ActiveDocument.Styles("_6_figure_caption")
        .Execute Replace:=wdReplaceOne
        Selection.MoveRight wdCharacter, 1
        Else
        Selection.MoveRight wdCharacter, 1
        End If
        Else
         
        Exit Do
        End If
        Loop
    End With
    
    With Selection.Find
        .ClearFormatting
        .Replacement.ClearFormatting
        
        .Text = "Figure A[0-9]{1,}. "
       
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        '.Format = True
        .MatchCase = False
        .MatchWholeWord = False
        .MatchByte = False
        .MatchAllWordForms = False
        .MatchSoundsLike = False
        .MatchWildcards = True
        Do
        .Execute
        If .Found Then
        If Asc(Selection.Range.Previous) = 13 Then
        .Replacement.Style = ActiveDocument.Styles("_6_figure_caption")
        .Execute Replace:=wdReplaceOne
        Selection.MoveRight wdCharacter, 1
        Else
        Selection.MoveRight wdCharacter, 1
        End If
        Else
         
        Exit Do
        End If
        Loop
    End With
    
    'With Selection.Find
       ' .ClearFormatting
       ' .Replacement.ClearFormatting
       ' .Replacement.Style = ActiveDocument.Styles("_6_figure_caption")
      '  .Text = "Figure [0-9]{1,}. "
      '  .Replacement.Text = ""
       ' .Forward = True
      '  .Wrap = wdFindContinue
        '.Format = True
      '  .MatchCase = False
      ' .MatchWholeWord = False
       ' .MatchByte = False
       ' .MatchAllWordForms = False
       ' .MatchSoundsLike = False
      '  .MatchWildcards = True
      '  .Execute Replace:=wdReplaceAll
    'End With
    
End Sub
Sub chart_caption()
' apply style on figure caption
    Selection.HomeKey wdStory

    With Selection.Find
        .ClearFormatting
        .Replacement.ClearFormatting
        
        .Text = "Chart [0-9]{1,}. "
       
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        '.Format = True
        .MatchCase = False
        .MatchWholeWord = False
        .MatchByte = False
        .MatchAllWordForms = False
        .MatchSoundsLike = False
        .MatchWildcards = True
        Do
        .Execute
        If .Found Then
        If Asc(Selection.Range.Previous) = 13 Then
        .Replacement.Style = ActiveDocument.Styles("_6_figure_caption")
        .Execute Replace:=wdReplaceOne
        Selection.MoveRight wdCharacter, 1
        Else
        Selection.MoveRight wdCharacter, 1
        End If
        Else
         
        Exit Do
        End If
        Loop
    End With
    
    With Selection.Find
        .ClearFormatting
        .Replacement.ClearFormatting
        
        .Text = "Chart A[0-9]{1,}. "
       
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        '.Format = True
        .MatchCase = False
        .MatchWholeWord = False
        .MatchByte = False
        .MatchAllWordForms = False
        .MatchSoundsLike = False
        .MatchWildcards = True
        Do
        .Execute
        If .Found Then
        If Asc(Selection.Range.Previous) = 13 Then
        .Replacement.Style = ActiveDocument.Styles("_6_figure_caption")
        .Execute Replace:=wdReplaceOne
        Selection.MoveRight wdCharacter, 1
        Else
        Selection.MoveRight wdCharacter, 1
        End If
        Else
         
        Exit Do
        End If
        Loop
    End With
    
    'With Selection.Find
     '   .ClearFormatting
      '  .Replacement.ClearFormatting
     '   .Replacement.Style = ActiveDocument.Styles("_6_figure_caption")
     '   .Text = "Chart [0-9]{1,}. "
     '   .Replacement.Text = ""
      '  .Forward = True
      '  .Wrap = wdFindContinue
        '.Format = True
      '  .MatchCase = False
      '  .MatchWholeWord = False
      '  .MatchByte = False
      '  .MatchAllWordForms = False
      '  .MatchSoundsLike = False
     '   .MatchWildcards = True
      '  .Execute Replace:=wdReplaceAll
    'End With
    
End Sub
    
Sub scheme_caption()
' apply style on figure caption
    Selection.HomeKey wdStory

    With Selection.Find
        .ClearFormatting
        .Replacement.ClearFormatting
        
        .Text = "Scheme [0-9]{1,}. "
       
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        '.Format = True
        .MatchCase = False
        .MatchWholeWord = False
        .MatchByte = False
        .MatchAllWordForms = False
        .MatchSoundsLike = False
        .MatchWildcards = True
        Do
        .Execute
        If .Found Then
        If Asc(Selection.Range.Previous) = 13 Then
        .Replacement.Style = ActiveDocument.Styles("_6_figure_caption")
        .Execute Replace:=wdReplaceOne
        Selection.MoveRight wdCharacter, 1
        Else
        Selection.MoveRight wdCharacter, 1
        End If
        Else
         
        Exit Do
        End If
        Loop
    End With
    
    With Selection.Find
        .ClearFormatting
        .Replacement.ClearFormatting
        
        .Text = "Scheme A[0-9]{1,}. "
       
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        '.Format = True
        .MatchCase = False
        .MatchWholeWord = False
        .MatchByte = False
        .MatchAllWordForms = False
        .MatchSoundsLike = False
        .MatchWildcards = True
        Do
        .Execute
        If .Found Then
        If Asc(Selection.Range.Previous) = 13 Then
        .Replacement.Style = ActiveDocument.Styles("_6_figure_caption")
        .Execute Replace:=wdReplaceOne
        Selection.MoveRight wdCharacter, 1
        Else
        Selection.MoveRight wdCharacter, 1
        End If
        Else
         
        Exit Do
        End If
        Loop
    End With
    
   ' With Selection.Find
     '   .ClearFormatting
     '   .Replacement.ClearFormatting
     '   .Replacement.Style = ActiveDocument.Styles("_6_figure_caption")
     '   .Text = "Scheme [0-9]{1,}. "
     '   .Replacement.Text = ""
     '   .Forward = True
     '   .Wrap = wdFindContinue
        '.Format = True
     '   .MatchCase = False
      '  .MatchWholeWord = False
      '  .MatchByte = False
      '  .MatchAllWordForms = False
      '  .MatchSoundsLike = False
      '  .MatchWildcards = True
     '   .Execute Replace:=wdReplaceAll
   ' End With
    
End Sub

Sub figure_body()
' apply style on figure caption
    With Selection.Find
        .ClearFormatting
        .Replacement.ClearFormatting
        .Replacement.Style = ActiveDocument.Styles("_6_figure_body")
        .Text = "^g"
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        '.Format = True
        .MatchCase = False
        .MatchWholeWord = False
        .MatchByte = False
        .MatchAllWordForms = False
        .MatchSoundsLike = False
        .MatchWildcards = False
        .Execute Replace:=wdReplaceAll
    End With
    
End Sub
Sub chart_body()
' apply style on figure caption
    With Selection.Find
        .ClearFormatting
        .Replacement.ClearFormatting
        .Replacement.Style = ActiveDocument.Styles("_6_figure_body")
        .Text = "^g"
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        '.Format = True
        .MatchCase = False
        .MatchWholeWord = False
        .MatchByte = False
        .MatchAllWordForms = False
        .MatchSoundsLike = False
        .MatchWildcards = False
        .Execute Replace:=wdReplaceAll
    End With
    
End Sub
Sub scheme_body()
' apply style on scheme caption
    With Selection.Find
        .ClearFormatting
        .Replacement.ClearFormatting
        .Replacement.Style = ActiveDocument.Styles("_6_figure_body")
        .Text = "^g"
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        '.Format = True
        .MatchCase = False
        .MatchWholeWord = False
        .MatchByte = False
        .MatchAllWordForms = False
        .MatchSoundsLike = False
        .MatchWildcards = False
        .Execute Replace:=wdReplaceAll
    End With
    
End Sub

Sub table_caption()
' apply style on table caption
    Selection.HomeKey wdStory

    With Selection.Find
        .ClearFormatting
        .Replacement.ClearFormatting
        
        .Text = "Table [0-9]{1,}. "
       
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        '.Format = True
        .MatchCase = False
        .MatchWholeWord = False
        .MatchByte = False
        .MatchAllWordForms = False
        .MatchSoundsLike = False
        .MatchWildcards = True
        Do
        .Execute
        If .Found Then
        If Asc(Selection.Range.Previous) = 13 Then
        .Replacement.Style = ActiveDocument.Styles("_5_table_caption")
        .Execute Replace:=wdReplaceOne
        Selection.MoveRight wdCharacter, 1
        Else
        Selection.MoveRight wdCharacter, 1
        End If
        Else
         
        Exit Do
        End If
        Loop
    End With
    
    With Selection.Find
        .ClearFormatting
        .Replacement.ClearFormatting
        
        .Text = "Table A[0-9]{1,}. "
       
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        '.Format = True
        .MatchCase = False
        .MatchWholeWord = False
        .MatchByte = False
        .MatchAllWordForms = False
        .MatchSoundsLike = False
        .MatchWildcards = True
        Do
        .Execute
        If .Found Then
        If Asc(Selection.Range.Previous) = 13 Then
        .Replacement.Style = ActiveDocument.Styles("_5_table_caption")
        .Execute Replace:=wdReplaceOne
        Selection.MoveRight wdCharacter, 1
        Else
        Selection.MoveRight wdCharacter, 1
        End If
        Else
         
        Exit Do
        End If
        Loop
    End With
    
    'With Selection.Find
      '  .ClearFormatting
      '  .Replacement.ClearFormatting
      '  .Replacement.Style = ActiveDocument.Styles("_5_table_caption")
      '  .Text = "Table [0-9]{1,}. "
      '  .Replacement.Text = ""
      '  .Forward = True
      '  .Wrap = wdFindContinue
        '.Format = True
       ' .MatchCase = False
      '  .MatchWholeWord = False
      '  .MatchByte = False
      '  .MatchAllWordForms = False
      '  .MatchSoundsLike = False
      '  .MatchWildcards = True
     '   .Execute Replace:=wdReplaceAll
   ' End With
    
End Sub


Sub figure_citation()
' find path like "Figure plus number" in text and then apply style
    With Selection.Find
        .ClearFormatting
        .Replacement.ClearFormatting
        .Replacement.Style = ActiveDocument.Styles("_4_text_float_citation")
        .Text = "Figure [0-9]{1,}"
        .Font.Bold = False
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        .Format = True
        .MatchCase = False
        .MatchWholeWord = False
        .MatchByte = False
        .MatchAllWordForms = False
        .MatchSoundsLike = False
        .MatchWildcards = True
        .Execute Replace:=wdReplaceAll
    End With
    With Selection.Find
        .ClearFormatting
        .Replacement.ClearFormatting
        .Replacement.Style = ActiveDocument.Styles("_4_text_float_citation")
        .Text = "Figures [0-9]{1,} and [0-9]{1,}"
        
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        .Format = True
        .MatchCase = False
        .MatchWholeWord = False
        .MatchByte = False
        .MatchAllWordForms = False
        .MatchSoundsLike = False
        .MatchWildcards = True
        .Execute Replace:=wdReplaceAll
    End With
    
    With Selection.Find
        .ClearFormatting
        .Replacement.ClearFormatting
        .Replacement.Style = ActiveDocument.Styles("_4_text_float_citation")
        .Text = "Figures [0-9]{1,}, [0-9]{1,} and [0-9]{1,}"
        
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        .Format = True
        .MatchCase = False
        .MatchWholeWord = False
        .MatchByte = False
        .MatchAllWordForms = False
        .MatchSoundsLike = False
        .MatchWildcards = True
        .Execute Replace:=wdReplaceAll
    End With
    With Selection.Find
        .ClearFormatting
        .Replacement.ClearFormatting
        .Replacement.Style = ActiveDocument.Styles("_4_text_float_citation")
        .Text = "Figures [0-9]{1,}?[0-9]{1,}"
        
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        .Format = True
        .MatchCase = False
        .MatchWholeWord = False
        .MatchByte = False
        .MatchAllWordForms = False
        .MatchSoundsLike = False
        .MatchWildcards = True
        .Execute Replace:=wdReplaceAll
    End With
   
End Sub
Sub box_citation()
' find path like "Figure plus number" in text and then apply style
    With Selection.Find
        .ClearFormatting
        .Replacement.ClearFormatting
        .Replacement.Style = ActiveDocument.Styles("_4_text_float_citation")
        .Text = "Box [0-9]{1,}"
        .Font.Bold = False
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        .Format = True
        .MatchCase = False
        .MatchWholeWord = False
        .MatchByte = False
        .MatchAllWordForms = False
        .MatchSoundsLike = False
        .MatchWildcards = True
        .Execute Replace:=wdReplaceAll
    End With
    With Selection.Find
        .ClearFormatting
        .Replacement.ClearFormatting
        .Replacement.Style = ActiveDocument.Styles("_4_text_float_citation")
        .Text = "Boxes [0-9]{1,} and [0-9]{1,}"
        
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        .Format = True
        .MatchCase = False
        .MatchWholeWord = False
        .MatchByte = False
        .MatchAllWordForms = False
        .MatchSoundsLike = False
        .MatchWildcards = True
        .Execute Replace:=wdReplaceAll
    End With
    
    With Selection.Find
        .ClearFormatting
        .Replacement.ClearFormatting
        .Replacement.Style = ActiveDocument.Styles("_4_text_float_citation")
        .Text = "Boxes [0-9]{1,}, [0-9]{1,} and [0-9]{1,}"
        
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        .Format = True
        .MatchCase = False
        .MatchWholeWord = False
        .MatchByte = False
        .MatchAllWordForms = False
        .MatchSoundsLike = False
        .MatchWildcards = True
        .Execute Replace:=wdReplaceAll
    End With
    With Selection.Find
        .ClearFormatting
        .Replacement.ClearFormatting
        .Replacement.Style = ActiveDocument.Styles("_4_text_float_citation")
        .Text = "Boxes [0-9]{1,}?[0-9]{1,}"
        
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        .Format = True
        .MatchCase = False
        .MatchWholeWord = False
        .MatchByte = False
        .MatchAllWordForms = False
        .MatchSoundsLike = False
        .MatchWildcards = True
        .Execute Replace:=wdReplaceAll
    End With
   
End Sub



Sub Appendix_citation()

    With Selection.Find
        .ClearFormatting
        .Replacement.ClearFormatting
        .Replacement.Style = ActiveDocument.Styles("_4_text_float_citation")
        .Text = "Appendix [A-Z]"
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        .Format = True
        .MatchCase = False
        .MatchWholeWord = False
        .MatchByte = False
        .MatchAllWordForms = False
        .MatchSoundsLike = False
        .MatchWildcards = True
        .Execute Replace:=wdReplaceAll
    End With
    With Selection.Find
        .ClearFormatting
        .Replacement.ClearFormatting
        .Replacement.Style = ActiveDocument.Styles("_4_text_float_citation")
        .Text = "Appendix [A-Z].[0-9]{1,}"
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        .Format = True
        .MatchCase = False
        .MatchWholeWord = False
        .MatchByte = False
        .MatchAllWordForms = False
        .MatchSoundsLike = False
        .MatchWildcards = True
        .Execute Replace:=wdReplaceAll
    End With
    With Selection.Find
        .ClearFormatting
        .Replacement.ClearFormatting
        .Replacement.Style = ActiveDocument.Styles("_4_text_float_citation")
        .Text = "Appendix [A-Z].[0-9]{1,}.[0-9]{1,}"
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        .Format = True
        .MatchCase = False
        .MatchWholeWord = False
        .MatchByte = False
        .MatchAllWordForms = False
        .MatchSoundsLike = False
        .MatchWildcards = True
        .Execute Replace:=wdReplaceAll
    End With
    With Selection.Find
        .ClearFormatting
        .Replacement.ClearFormatting
        .Replacement.Style = ActiveDocument.Styles("_4_text_float_citation")
        .Text = "Figure [A-Z][0-9]{1,}"
        .Font.Bold = False
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        .Format = True
        .MatchCase = False
        .MatchWholeWord = False
        .MatchByte = False
        .MatchAllWordForms = False
        .MatchSoundsLike = False
        .MatchWildcards = True
        .Execute Replace:=wdReplaceAll
    End With
    With Selection.Find
        .ClearFormatting
        .Replacement.ClearFormatting
        .Replacement.Style = ActiveDocument.Styles("_4_text_float_citation")
        .Text = "Figures [A-Z][0-9]{1,} and [A-Z][0-9]{1,}"
        
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        .Format = True
        .MatchCase = False
        .MatchWholeWord = False
        .MatchByte = False
        .MatchAllWordForms = False
        .MatchSoundsLike = False
        .MatchWildcards = True
        .Execute Replace:=wdReplaceAll
    End With
    
    With Selection.Find
        .ClearFormatting
        .Replacement.ClearFormatting
        .Replacement.Style = ActiveDocument.Styles("_4_text_float_citation")
        .Text = "Figures [A-Z][0-9]{1,}, [A-Z][0-9]{1,} and [A-Z][0-9]{1,}"
        
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        .Format = True
        .MatchCase = False
        .MatchWholeWord = False
        .MatchByte = False
        .MatchAllWordForms = False
        .MatchSoundsLike = False
        .MatchWildcards = True
        .Execute Replace:=wdReplaceAll
    End With
    With Selection.Find
        .ClearFormatting
        .Replacement.ClearFormatting
        .Replacement.Style = ActiveDocument.Styles("_4_text_float_citation")
        .Text = "Figures [A-Z][0-9]{1,}?[A-Z][0-9]{1,}"
        
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        .Format = True
        .MatchCase = False
        .MatchWholeWord = False
        .MatchByte = False
        .MatchAllWordForms = False
        .MatchSoundsLike = False
        .MatchWildcards = True
        .Execute Replace:=wdReplaceAll
    End With
    With Selection.Find
        .ClearFormatting
        .Replacement.ClearFormatting
        .Replacement.Style = ActiveDocument.Styles("_4_text_float_citation")
        .Text = "Table [A-Z][0-9]{1,}"
        .Font.Bold = False
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        .Format = True
        .MatchCase = False
        .MatchWholeWord = False
        .MatchByte = False
        .MatchAllWordForms = False
        .MatchSoundsLike = False
        .MatchWildcards = True
        .Execute Replace:=wdReplaceAll
    End With
    With Selection.Find
        .ClearFormatting
        .Replacement.ClearFormatting
        .Replacement.Style = ActiveDocument.Styles("_4_text_float_citation")
        .Text = "Tables [A-Z][0-9]{1,} and [A-Z][0-9]{1,}"
        
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        .Format = True
        .MatchCase = False
        .MatchWholeWord = False
        .MatchByte = False
        .MatchAllWordForms = False
        .MatchSoundsLike = False
        .MatchWildcards = True
        .Execute Replace:=wdReplaceAll
    End With
    
    With Selection.Find
        .ClearFormatting
        .Replacement.ClearFormatting
        .Replacement.Style = ActiveDocument.Styles("_4_text_float_citation")
        .Text = "Tables [A-Z][0-9]{1,}, [A-Z][0-9]{1,} and [A-Z][0-9]{1,}"
        
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        .Format = True
        .MatchCase = False
        .MatchWholeWord = False
        .MatchByte = False
        .MatchAllWordForms = False
        .MatchSoundsLike = False
        .MatchWildcards = True
        .Execute Replace:=wdReplaceAll
    End With
    With Selection.Find
        .ClearFormatting
        .Replacement.ClearFormatting
        .Replacement.Style = ActiveDocument.Styles("_4_text_float_citation")
        .Text = "Tables [A-Z][0-9]{1,}?[A-Z][0-9]{1,}"
        
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        .Format = True
        .MatchCase = False
        .MatchWholeWord = False
        .MatchByte = False
        .MatchAllWordForms = False
        .MatchSoundsLike = False
        .MatchWildcards = True
        .Execute Replace:=wdReplaceAll
    End With
End Sub
Sub Supplementary_citation()

    With Selection.Find
        .ClearFormatting
        .Replacement.ClearFormatting
        .Replacement.Style = ActiveDocument.Styles("_4_text_float_citation")
        .Text = "Supplementary Materials"
        .Font.Bold = False
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        .Format = True
        .MatchCase = False
        .MatchWholeWord = False
        .MatchByte = False
        .MatchAllWordForms = False
        .MatchSoundsLike = False
        .MatchWildcards = True
        .Execute Replace:=wdReplaceAll
    End With
    With Selection.Find
        .ClearFormatting
        .Replacement.ClearFormatting
        .Replacement.Style = ActiveDocument.Styles("_4_text_float_citation")
        .Text = "Figure S[0-9]{1,}"
        .Font.Bold = False
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        .Format = True
        .MatchCase = False
        .MatchWholeWord = False
        .MatchByte = False
        .MatchAllWordForms = False
        .MatchSoundsLike = False
        .MatchWildcards = True
        .Execute Replace:=wdReplaceAll
    End With
    With Selection.Find
        .ClearFormatting
        .Replacement.ClearFormatting
        .Replacement.Style = ActiveDocument.Styles("_4_text_float_citation")
        .Text = "Figures S[0-9]{1,} and S[0-9]{1,}"
        
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        .Format = True
        .MatchCase = False
        .MatchWholeWord = False
        .MatchByte = False
        .MatchAllWordForms = False
        .MatchSoundsLike = False
        .MatchWildcards = True
        .Execute Replace:=wdReplaceAll
    End With
    
    With Selection.Find
        .ClearFormatting
        .Replacement.ClearFormatting
        .Replacement.Style = ActiveDocument.Styles("_4_text_float_citation")
        .Text = "Figures S[0-9]{1,}, S[0-9]{1,} and S[0-9]{1,}"
        
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        .Format = True
        .MatchCase = False
        .MatchWholeWord = False
        .MatchByte = False
        .MatchAllWordForms = False
        .MatchSoundsLike = False
        .MatchWildcards = True
        .Execute Replace:=wdReplaceAll
    End With
    With Selection.Find
        .ClearFormatting
        .Replacement.ClearFormatting
        .Replacement.Style = ActiveDocument.Styles("_4_text_float_citation")
        .Text = "Figures S[0-9]{1,}?S[0-9]{1,}"
        
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        .Format = True
        .MatchCase = False
        .MatchWholeWord = False
        .MatchByte = False
        .MatchAllWordForms = False
        .MatchSoundsLike = False
        .MatchWildcards = True
        .Execute Replace:=wdReplaceAll
    End With
    With Selection.Find
        .ClearFormatting
        .Replacement.ClearFormatting
        .Replacement.Style = ActiveDocument.Styles("_4_text_float_citation")
        .Text = "Table S[0-9]{1,}"
        .Font.Bold = False
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        .Format = True
        .MatchCase = False
        .MatchWholeWord = False
        .MatchByte = False
        .MatchAllWordForms = False
        .MatchSoundsLike = False
        .MatchWildcards = True
        .Execute Replace:=wdReplaceAll
    End With
    With Selection.Find
        .ClearFormatting
        .Replacement.ClearFormatting
        .Replacement.Style = ActiveDocument.Styles("_4_text_float_citation")
        .Text = "Tables S[0-9]{1,} and S[0-9]{1,}"
        
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        .Format = True
        .MatchCase = False
        .MatchWholeWord = False
        .MatchByte = False
        .MatchAllWordForms = False
        .MatchSoundsLike = False
        .MatchWildcards = True
        .Execute Replace:=wdReplaceAll
    End With
    
    With Selection.Find
        .ClearFormatting
        .Replacement.ClearFormatting
        .Replacement.Style = ActiveDocument.Styles("_4_text_float_citation")
        .Text = "Tables S[0-9]{1,}, S[0-9]{1,} and S[0-9]{1,}"
        
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        .Format = True
        .MatchCase = False
        .MatchWholeWord = False
        .MatchByte = False
        .MatchAllWordForms = False
        .MatchSoundsLike = False
        .MatchWildcards = True
        .Execute Replace:=wdReplaceAll
    End With
    With Selection.Find
        .ClearFormatting
        .Replacement.ClearFormatting
        .Replacement.Style = ActiveDocument.Styles("_4_text_float_citation")
        .Text = "Tables S[0-9]{1,}?S[0-9]{1,}"
        
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        .Format = True
        .MatchCase = False
        .MatchWholeWord = False
        .MatchByte = False
        .MatchAllWordForms = False
        .MatchSoundsLike = False
        .MatchWildcards = True
        .Execute Replace:=wdReplaceAll
    End With
End Sub





Sub chart_citation()
' find path like "Figure plus number" in text and then apply style
    With Selection.Find
        .ClearFormatting
        .Replacement.ClearFormatting
        .Replacement.Style = ActiveDocument.Styles("_4_text_float_citation")
        .Text = "Chart [0-9]{1,}"
        .Font.Bold = False
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        .Format = True
        .MatchCase = False
        .MatchWholeWord = False
        .MatchByte = False
        .MatchAllWordForms = False
        .MatchSoundsLike = False
        .MatchWildcards = True
        .Execute Replace:=wdReplaceAll
    End With
    With Selection.Find
        .ClearFormatting
        .Replacement.ClearFormatting
        .Replacement.Style = ActiveDocument.Styles("_4_text_float_citation")
        .Text = "Charts [0-9]{1,} and [0-9]{1,}"
        
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        .Format = True
        .MatchCase = False
        .MatchWholeWord = False
        .MatchByte = False
        .MatchAllWordForms = False
        .MatchSoundsLike = False
        .MatchWildcards = True
        .Execute Replace:=wdReplaceAll
    End With
    
    With Selection.Find
        .ClearFormatting
        .Replacement.ClearFormatting
        .Replacement.Style = ActiveDocument.Styles("_4_text_float_citation")
        .Text = "Charts [0-9]{1,}, [0-9]{1,} and [0-9]{1,}"
        
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        .Format = True
        .MatchCase = False
        .MatchWholeWord = False
        .MatchByte = False
        .MatchAllWordForms = False
        .MatchSoundsLike = False
        .MatchWildcards = True
        .Execute Replace:=wdReplaceAll
    End With
    With Selection.Find
        .ClearFormatting
        .Replacement.ClearFormatting
        .Replacement.Style = ActiveDocument.Styles("_4_text_float_citation")
        .Text = "Charts [0-9]{1,}?[0-9]{1,}"
        
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        .Format = True
        .MatchCase = False
        .MatchWholeWord = False
        .MatchByte = False
        .MatchAllWordForms = False
        .MatchSoundsLike = False
        .MatchWildcards = True
        .Execute Replace:=wdReplaceAll
    End With
End Sub


Sub scheme_citation()
' find path like "Figure plus number" in text and then apply style
    With Selection.Find
        .ClearFormatting
        .Replacement.ClearFormatting
        .Replacement.Style = ActiveDocument.Styles("_4_text_float_citation")
        .Text = "Scheme [0-9]{1,}"
        .Font.Bold = False
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        .Format = True
        .MatchCase = False
        .MatchWholeWord = False
        .MatchByte = False
        .MatchAllWordForms = False
        .MatchSoundsLike = False
        .MatchWildcards = True
        .Execute Replace:=wdReplaceAll
    End With
    With Selection.Find
        .ClearFormatting
        .Replacement.ClearFormatting
        .Replacement.Style = ActiveDocument.Styles("_4_text_float_citation")
        .Text = "Schemes [0-9]{1,} and [0-9]{1,}"
        
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        .Format = True
        .MatchCase = False
        .MatchWholeWord = False
        .MatchByte = False
        .MatchAllWordForms = False
        .MatchSoundsLike = False
        .MatchWildcards = True
        .Execute Replace:=wdReplaceAll
    End With
    
    With Selection.Find
        .ClearFormatting
        .Replacement.ClearFormatting
        .Replacement.Style = ActiveDocument.Styles("_4_text_float_citation")
        .Text = "Schemes [0-9]{1,}, [0-9]{1,} and [0-9]{1,}"
        
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        .Format = True
        .MatchCase = False
        .MatchWholeWord = False
        .MatchByte = False
        .MatchAllWordForms = False
        .MatchSoundsLike = False
        .MatchWildcards = True
        .Execute Replace:=wdReplaceAll
    End With
    With Selection.Find
        .ClearFormatting
        .Replacement.ClearFormatting
        .Replacement.Style = ActiveDocument.Styles("_4_text_float_citation")
        .Text = "Schemes [0-9]{1,}?[0-9]{1,}"
        
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        .Format = True
        .MatchCase = False
        .MatchWholeWord = False
        .MatchByte = False
        .MatchAllWordForms = False
        .MatchSoundsLike = False
        .MatchWildcards = True
        .Execute Replace:=wdReplaceAll
    End With
End Sub

Sub table_citation()
' find path like "Table plus number" in text and then apply style
    With Selection.Find
        .ClearFormatting
        .Replacement.ClearFormatting
        .Replacement.Style = ActiveDocument.Styles("_4_text_float_citation")
        .Text = "Table [0-9]{1,}"
        .Font.Bold = False
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        .Format = True
        .MatchCase = False
        .MatchWholeWord = False
        .MatchByte = False
        .MatchAllWordForms = False
        .MatchSoundsLike = False
        .MatchWildcards = True
        .Execute Replace:=wdReplaceAll
    End With
    With Selection.Find
        .ClearFormatting
        .Replacement.ClearFormatting
        .Replacement.Style = ActiveDocument.Styles("_4_text_float_citation")
        .Text = "Tables [0-9]{1,}, [0-9]{1,} and [0-9]{1,}"
        
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        .Format = True
        .MatchCase = False
        .MatchWholeWord = False
        .MatchByte = False
        .MatchAllWordForms = False
        .MatchSoundsLike = False
        .MatchWildcards = True
        .Execute Replace:=wdReplaceAll
    End With
    With Selection.Find
        .ClearFormatting
        .Replacement.ClearFormatting
        .Replacement.Style = ActiveDocument.Styles("_4_text_float_citation")
        .Text = "Tables [0-9]{1,} and [0-9]{1,}"
        
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        .Format = True
        .MatchCase = False
        .MatchWholeWord = False
        .MatchByte = False
        .MatchAllWordForms = False
        .MatchSoundsLike = False
        .MatchWildcards = True
        .Execute Replace:=wdReplaceAll
    End With
    With Selection.Find
        .ClearFormatting
        .Replacement.ClearFormatting
        .Replacement.Style = ActiveDocument.Styles("_4_text_float_citation")
        .Text = "Tables [0-9]{1,}?[0-9]{1,}"
        
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        .Format = True
        .MatchCase = False
        .MatchWholeWord = False
        .MatchByte = False
        .MatchAllWordForms = False
        .MatchSoundsLike = False
        .MatchWildcards = True
        .Execute Replace:=wdReplaceAll
    End With
End Sub

Sub number_citation()
' pply style on number in "[]"
' ???? want - be ,
Selection.HomeKey wdStory
    With Selection.Find
        .ClearFormatting
        .Text = "["
        .Forward = True
        .Wrap = wdFindStop
        .MatchWildcards = False
        Do
            .Execute
            If .Found Then
                With Selection
                    .MoveEndWhile ("0123456789," & ChrW(8211))
                    If Selection.Next(wdCharacter, 1) = "]" Then
                        Dim myrange As Range
                        Selection.Range.Select
                        Set myrange = Selection.Range
                        myrange.SetRange Start:=Selection.Range.Start, End:=Selection.Range.End + 1
                      myrange.Style = ActiveDocument.Styles("_4_text_citation")
                    End If
                    .Collapse wdCollapseEnd
                End With
            Else
                Exit Do
            End If
        Loop
    End With
    
End Sub

Sub section_citation()
' pply style on number in "section"
' ???? want - be ,
    With Selection.Find
        .ClearFormatting
        .Replacement.ClearFormatting
        .Replacement.Style = ActiveDocument.Styles("_4_text_float_citation")
        .Text = "Section [0-9]{1,}"
        
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        .Format = True
        .MatchCase = False
        .MatchWholeWord = False
        .MatchByte = False
        .MatchAllWordForms = False
        .MatchSoundsLike = False
        .MatchWildcards = True
        .Execute Replace:=wdReplaceAll
    End With
    With Selection.Find
        .ClearFormatting
        .Replacement.ClearFormatting
        .Replacement.Style = ActiveDocument.Styles("_4_text_float_citation")
        .Text = "Section [0-9]{1,}.[0-9]{1,}"
        
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        .Format = True
        .MatchCase = False
        .MatchWholeWord = False
        .MatchByte = False
        .MatchAllWordForms = False
        .MatchSoundsLike = False
        .MatchWildcards = True
        .Execute Replace:=wdReplaceAll
    End With
    With Selection.Find
        .ClearFormatting
        .Replacement.ClearFormatting
        .Replacement.Style = ActiveDocument.Styles("_4_text_float_citation")
        .Text = "Section [0-9]{1,}.[0-9]{1,}.[0-9]{1,}"
        
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        .Format = True
        .MatchCase = False
        .MatchWholeWord = False
        .MatchByte = False
        .MatchAllWordForms = False
        .MatchSoundsLike = False
        .MatchWildcards = True
        .Execute Replace:=wdReplaceAll
    End With
    With Selection.Find
        .ClearFormatting
        .Replacement.ClearFormatting
        .Replacement.Style = ActiveDocument.Styles("_4_text_float_citation")
        .Text = "Sections [0-9]{1,} and [0-9]{1,}"
        
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        .Format = True
        .MatchCase = False
        .MatchWholeWord = False
        .MatchByte = False
        .MatchAllWordForms = False
        .MatchSoundsLike = False
        .MatchWildcards = True
        .Execute Replace:=wdReplaceAll
    End With
    With Selection.Find
        .ClearFormatting
        .Replacement.ClearFormatting
        .Replacement.Style = ActiveDocument.Styles("_4_text_float_citation")
        .Text = "Sections [0-9]{1,}, [0-9]{1,} and [0-9]{1,}"
        
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        .Format = True
        .MatchCase = False
        .MatchWholeWord = False
        .MatchByte = False
        .MatchAllWordForms = False
        .MatchSoundsLike = False
        .MatchWildcards = True
        .Execute Replace:=wdReplaceAll
    End With
    With Selection.Find
        .ClearFormatting
        .Replacement.ClearFormatting
        .Replacement.Style = ActiveDocument.Styles("_4_text_float_citation")
        .Text = "Sections [0-9]{1,}?[0-9]{1,}"
        
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        .Format = True
        .MatchCase = False
        .MatchWholeWord = False
        .MatchByte = False
        .MatchAllWordForms = False
        .MatchSoundsLike = False
        .MatchWildcards = True
        .Execute Replace:=wdReplaceAll
    End With
End Sub
Sub replace_semicolon()
  With Selection.Find
        .ClearFormatting
        .MatchWildcards = True
        .Text = "\(accessed on *\)"
        .Replacement.Text = ""
        .Execute Replace:=wdReplaceAll
    End With
  With Selection.Find
        .ClearFormatting
        .MatchWildcards = True
        .Text = "; "
        .Replacement.Text = ")^p("
        .Execute Replace:=wdReplaceAll
    End With
    With ActiveDocument.Content.Find
        .ClearFormatting
        .MatchWildcards = True
        .Text = "\, [!A-Z]@*[?ê?\)]"
        .Replacement.Text = ")"
        .Execute Replace:=wdReplaceAll
    End With
    With ActiveDocument.Content.Find
        .ClearFormatting
        .MatchWildcards = True
        .Text = "\("
        .Replacement.Text = ""
        .Execute Replace:=wdReplaceAll
    End With
    With ActiveDocument.Content.Find
        .ClearFormatting
        .MatchWildcards = True
        .Text = "\)"
        .Replacement.Text = ""
        .Execute Replace:=wdReplaceAll
    End With
    With ActiveDocument.Content.Find
        .ClearFormatting
        .MatchWildcards = False
        .Text = "^p^p"
        .Replacement.Text = "^p"
        .Execute Replace:=wdReplaceAll
    End With
End Sub

Sub replace_ack()
     With ActiveDocument.Content.Find
        .ClearFormatting
        .MatchWildcards = True
        .Text = "^13Supplementary Materials: *"
        .Replacement.Text = "^13Supplementary Materials^p"
        .Execute Replace:=wdReplaceAll
    End With
     With ActiveDocument.Content.Find
        .ClearFormatting
        .MatchWildcards = True
        .Text = "^13Acknowledgments: *"
        .Replacement.Text = "^13Acknowledgments^p"
        .Execute Replace:=wdReplaceAll
    End With
    
    With ActiveDocument.Content.Find
        .ClearFormatting
        .MatchWildcards = True
        .Text = "^13Acknowledgements: *"
        .Replacement.Text = "^13Acknowledgements^p"
        .Execute Replace:=wdReplaceAll
    End With
    
    With ActiveDocument.Content.Find
        .ClearFormatting
        .MatchWildcards = True
        .Text = "^13Author Contributions: *"
        .Replacement.Text = "^13Author Contributions^p"
        .Execute Replace:=wdReplaceAll
    End With
    With ActiveDocument.Content.Find
        .ClearFormatting
        .MatchWildcards = True
        .Text = "^13Conflicts of Interest: *"
        .Replacement.Text = "^13Conflicts of Interest^p"
        .Execute Replace:=wdReplaceAll
    End With
    With ActiveDocument.Content.Find
        .ClearFormatting
        .MatchWildcards = True
        .Text = "^13Funding: *"
        
        .Replacement.Text = "^13Funding^p"
        .Execute Replace:=wdReplaceAll
    End With
End Sub
Sub supplementary_materials()
' make acknowledgements as 1st level
    With Selection.Find
    .ClearFormatting
    .Replacement.ClearFormatting
        .Text = "Supplementary Materials^13"
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        '.Format = True
        .MatchCase = False
        .MatchWholeWord = False
        .MatchByte = False
        .MatchAllWordForms = False
        .MatchSoundsLike = False
        .MatchWildcards = True
        
        .Execute
        If .Found Then
        If Asc(Selection.Range.Previous) = 13 Then
            Selection.HomeKey UNIT:=wdLine
            Selection.Style = ActiveDocument.Styles("_4_heading_1")
            Selection.MoveDown UNIT:=wdParagraph, count:=1
        End If
       End If
    End With
    
End Sub
Sub appendix()
' make acknowledgements as 1st level
    With Selection.Find
        .ClearFormatting
        .Text = "Appendix [A-Z]^13"
        .Format = False
        .Forward = True
        .Wrap = wdFindContinue
        .MatchCase = True
        .MatchWildcards = True
        .Replacement.Style = ActiveDocument.Styles("_4_heading_1")
        .Execute
        If .Found Then
        If Asc(Selection.Range.Previous) = 13 Then
           .Execute Replace:=wdReplaceAll
           End If
        End If
                  
    End With
    
    With Selection.Find
        .ClearFormatting
        .Text = "Appendix [A-Z].[0-9]{1,}^13"
        .Format = False
        .Forward = True
        .Wrap = wdFindContinue
        .MatchCase = True
        .MatchWildcards = True
        .Replacement.Style = ActiveDocument.Styles("_4_heading_2")
        .Execute
        If .Found Then
        If Asc(Selection.Range.Previous) = 13 Then
           .Execute Replace:=wdReplaceAll
           End If
        End If
                  
    End With
    
    With Selection.Find
        .ClearFormatting
        .Text = "Appendix [A-Z].[0-9]{1,}.[0-9]{1,}^13"
        .Format = False
        .Forward = True
        .Wrap = wdFindContinue
        .MatchCase = True
        .MatchWildcards = True
        .Replacement.Style = ActiveDocument.Styles("_4_heading_3")
        .Execute
        If .Found Then
        If Asc(Selection.Range.Previous) = 13 Then
           .Execute Replace:=wdReplaceAll
           End If
        End If
                  
    End With
    
    With Selection.Find
        .ClearFormatting
        .Text = "Appendix [A-Z] ^13"
        .Format = False
        .Forward = True
        .Wrap = wdFindContinue
        .MatchCase = True
        .MatchWildcards = True
        .Replacement.Style = ActiveDocument.Styles("_4_heading_1")
        .Execute
        If .Found Then
        If Asc(Selection.Range.Previous) = 13 Then
           .Execute Replace:=wdReplaceAll
           End If
        End If
                  
    End With
    
    With Selection.Find
        .ClearFormatting
        .Text = "Appendix [A-Z].[0-9]{1,} ^13"
        .Format = False
        .Forward = True
        .Wrap = wdFindContinue
        .MatchCase = True
        .MatchWildcards = True
        .Replacement.Style = ActiveDocument.Styles("_4_heading_2")
        .Execute
        If .Found Then
        If Asc(Selection.Range.Previous) = 13 Then
           .Execute Replace:=wdReplaceAll
           End If
        End If
                  
    End With
    
    With Selection.Find
        .ClearFormatting
        .Text = "Appendix [A-Z].[0-9]{1,}.[0-9]{1,} ^13"
        .Format = False
        .Forward = True
        .Wrap = wdFindContinue
        .MatchCase = True
        .MatchWildcards = True
        .Replacement.Style = ActiveDocument.Styles("_4_heading_3")
        .Execute
        If .Found Then
        If Asc(Selection.Range.Previous) = 13 Then
           .Execute Replace:=wdReplaceAll
           End If
        End If
                  
    End With
End Sub
Sub acknowledgements()
' make acknowledgements as 1st level
    With Selection.Find
        .Text = "Acknowledg"
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        .Format = False
        .MatchCase = False
        .MatchWholeWord = False
        .MatchByte = True
        .MatchWildcards = True
        .MatchSoundsLike = False
        .MatchAllWordForms = False
        .Execute
        If .Found = True Then
            Selection.HomeKey UNIT:=wdLine
            Selection.Style = ActiveDocument.Styles("_4_heading_1")
            Selection.MoveDown UNIT:=wdParagraph, count:=1
        End If
    End With
    
End Sub

Sub references()
' apply styles on the back part
    
    With Selection.Find
        .Text = "^13Reference^13"
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        .Format = False
        .MatchCase = True
        .MatchWholeWord = False
        .MatchByte = True
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
        .Execute
        If .Found = True Then
            Selection.EndKey UNIT:=wdLine
            ' make acknowledgements as 1st level
            Selection.Style = ActiveDocument.Styles("_4_heading_1")
            Selection.MoveDown UNIT:=wdParagraph, count:=1
            Selection.EndKey UNIT:=wdStory, Extend:=wdExtend
            ' apply styles on the rest of the article
            Selection.Style = ActiveDocument.Styles("_8_reference")
        End If
    End With
    With Selection.Find
        .Text = "^13References^13"
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        .Format = False
        .MatchCase = True
        .MatchWholeWord = False
        .MatchByte = True
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
        .Execute
        If .Found = True Then
            Selection.EndKey UNIT:=wdLine
            ' make acknowledgements as 1st level
            Selection.Style = ActiveDocument.Styles("_4_heading_1")
            Selection.MoveDown UNIT:=wdParagraph, count:=1
            Selection.EndKey UNIT:=wdStory, Extend:=wdExtend
            ' apply styles on the rest of the article
            Selection.Style = ActiveDocument.Styles("_8_reference")
        End If
    End With
    With Selection.Find
        .Text = "^13References and Notes^13"
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        .Format = False
        .MatchCase = True
        .MatchWholeWord = False
        .MatchByte = True
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
        .Execute
        If .Found = True Then
            Selection.EndKey UNIT:=wdLine
            ' make acknowledgements as 1st level
            Selection.Style = ActiveDocument.Styles("_4_heading_1")
            Selection.MoveDown UNIT:=wdParagraph, count:=1
            Selection.EndKey UNIT:=wdStory, Extend:=wdExtend
            ' apply styles on the rest of the article
            Selection.Style = ActiveDocument.Styles("_8_reference")
        End If
    End With
    
    With Selection.Find
        .Text = "^13Reference ^13"
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        .Format = False
        .MatchCase = True
        .MatchWholeWord = False
        .MatchByte = True
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
        .Execute
        If .Found = True Then
            Selection.EndKey UNIT:=wdLine
            ' make acknowledgements as 1st level
            Selection.Style = ActiveDocument.Styles("_4_heading_1")
            Selection.MoveDown UNIT:=wdParagraph, count:=1
            Selection.EndKey UNIT:=wdStory, Extend:=wdExtend
            ' apply styles on the rest of the article
            Selection.Style = ActiveDocument.Styles("_8_reference")
        End If
    End With
    With Selection.Find
        .Text = "^13References ^13"
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        .Format = False
        .MatchCase = True
        .MatchWholeWord = False
        .MatchByte = True
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
        .Execute
        If .Found = True Then
            Selection.EndKey UNIT:=wdLine
            ' make acknowledgements as 1st level
            Selection.Style = ActiveDocument.Styles("_4_heading_1")
            Selection.MoveDown UNIT:=wdParagraph, count:=1
            Selection.EndKey UNIT:=wdStory, Extend:=wdExtend
            ' apply styles on the rest of the article
            Selection.Style = ActiveDocument.Styles("_8_reference")
        End If
    End With
    With Selection.Find
        .Text = "^13References and Notes ^13"
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        .Format = False
        .MatchCase = True
        .MatchWholeWord = False
        .MatchByte = True
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
        .Execute
        If .Found = True Then
            Selection.EndKey UNIT:=wdLine
            ' make acknowledgements as 1st level
            Selection.Style = ActiveDocument.Styles("_4_heading_1")
            Selection.MoveDown UNIT:=wdParagraph, count:=1
            Selection.EndKey UNIT:=wdStory, Extend:=wdExtend
            ' apply styles on the rest of the article
            Selection.Style = ActiveDocument.Styles("_8_reference")
        End If
    End With
End Sub

Sub sample_availability()
' apply style on keywords, same as Yidong's
    ' keywords
    With Selection.Find
        .Text = "Sample Availability: "
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        .Format = False
        .MatchCase = False
        .MatchWholeWord = False
        .MatchByte = True
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
        .Execute
        If .Found Then
        Selection.MoveDown UNIT:=wdParagraph, count:=1, Extend:=wdExtend
        
        Selection.Style = ActiveDocument.Styles("_8_notes")
        End If
    End With
    'selection.MoveDown unit:=wdParagraph, count:=1
   ' selection.MoveDown unit:=wdParagraph, count:=1,
    'selection.Style = ActiveDocument.Styles("_3_keywords")
End Sub




Sub Search_Figure()
' used for checking if there is un-marked figure citation
    With Selection.Find
        .ClearFormatting
        .Text = "Figure [0-9]"
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        .Format = True
        .MatchCase = False
        .MatchWholeWord = False
        .MatchByte = False
        .MatchAllWordForms = False
        .MatchSoundsLike = False
        .MatchWildcards = True
        .Execute
    End With
End Sub

Sub Search_Table()
' used for checking if there is un-marked table citation
    With Selection.Find
        .ClearFormatting
        .Font.Bold = False
        .Text = "Table [0-9]"
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        .Format = True
        .MatchCase = False
        .MatchWholeWord = False
        .MatchByte = False
        .MatchAllWordForms = False
        .MatchSoundsLike = False
        .MatchWildcards = True
        .Execute
    End With
End Sub



Sub inline_graph()
' select paragraph first
    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    With Selection.Find
        .Text = "^g"
        .Replacement.Text = "(inline graph)"
        .Forward = True
        .Wrap = wdFindAsk
        .Format = True
        .MatchCase = False
        .MatchWholeWord = False
        .MatchByte = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Font.Position = 0
    Selection.Find.Execute Replace:=wdReplaceAll
End Sub

Sub figures_highlight()

    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    Selection.Find.Replacement.Font.Color = wdColorRed
    With Selection.Find
        .Text = "Figures"
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        .Format = True
        .MatchCase = True
        .MatchWholeWord = False
        .MatchByte = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
        
End Sub
Sub boxes_highlight()

    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    Selection.Find.Replacement.Font.Color = wdColorRed
    With Selection.Find
        .Text = "Boxes"
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        .Format = True
        .MatchCase = True
        .MatchWholeWord = False
        .MatchByte = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
        
End Sub
Sub charts_highlight()

    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    Selection.Find.Replacement.Font.Color = wdColorRed
    With Selection.Find
        .Text = "Charts"
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        .Format = True
        .MatchCase = True
        .MatchWholeWord = False
        .MatchByte = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
        
End Sub
Sub forthcoming_highlight()

    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    Selection.Find.Replacement.Font.Color = wdColorRed
    With Selection.Find
        .Text = "forthcoming"
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        .Format = True
        .MatchCase = True
        .MatchWholeWord = False
        .MatchByte = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
        
End Sub
Sub n_d_highlight()

    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    Selection.Find.Replacement.Font.Color = wdColorRed
    With Selection.Find
        .Text = "n.d."
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        .Format = True
        .MatchCase = True
        .MatchWholeWord = False
        .MatchByte = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
        
End Sub
Sub sections_highlight()

    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    Selection.Find.Replacement.Font.Color = wdColorRed
    With Selection.Find
        .Text = "Sections"
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        .Format = True
        .MatchCase = True
        .MatchWholeWord = False
        .MatchByte = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
        
End Sub

Sub schemes_highlight()

    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    Selection.Find.Replacement.Font.Color = wdColorRed
    With Selection.Find
        .Text = "Schemes"
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        .Format = True
        .MatchCase = True
        .MatchWholeWord = False
        .MatchByte = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
        
End Sub

Sub tables_highlight()

    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    Selection.Find.Replacement.Font.Color = wdColorRed
    With Selection.Find
        .Text = "Tables"
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        .Format = True
        .MatchCase = True
        .MatchWholeWord = False
        .MatchByte = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
        
End Sub
Sub Appendices_highlight()

    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    Selection.Find.Replacement.Font.Color = wdColorRed
    With Selection.Find
        .Text = "Appendices"
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        .Format = True
        .MatchCase = True
        .MatchWholeWord = False
        .MatchByte = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
        
End Sub

Sub Appendixes_highlight()

    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    Selection.Find.Replacement.Font.Color = wdColorRed
    With Selection.Find
        .Text = "Appendixes"
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        .Format = True
        .MatchCase = True
        .MatchWholeWord = False
        .MatchByte = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
        
End Sub


Sub font_color()

ActiveWindow.ActivePane.View.Zoom.Percentage = 90
Call ctrl_shft_F9
Call italic_red
Call sub_blue
Call sup_green
Call underline_orange
Call highlight_bold_space
Call highlight_sup_space
Call highlight_sub_space
Call figure_highlight
Call scheme_highlight
Call table_highlight
Call Chart_highlight
Call section_highlight
Call Appendix_highlight
Call www_highlight
Call http_highlight
Call small_caps_highlight
Call char2013
Call char2014
Call highlight_symbols
Call supplement_highlight
Call Box_highlight
Call forthcome_highlight
Call nd_highlight
End Sub

Sub highlight_symbols()
 
 Selection.Find.ClearFormatting
    With Selection.Find.Font
        .name = "Symbol"
    End With
    Selection.Find.Replacement.ClearFormatting
    Selection.Find.Replacement.Highlight = True
    With Selection.Find
        .Text = ""
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        .Format = True
        .MatchCase = False
        .MatchWholeWord = False
        .MatchByte = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
End Sub

Sub small_caps_highlight()
 
 Selection.Find.ClearFormatting
    With Selection.Find.Font
        .SmallCaps = True
    End With
    Selection.Find.Replacement.ClearFormatting
    Selection.Find.Replacement.Highlight = True
    With Selection.Find
        .Text = ""
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        .Format = True
        .MatchCase = False
        .MatchWholeWord = False
        .MatchByte = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
End Sub


Sub char2013()

    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    Options.DefaultHighlightColorIndex = wdGreen
    Selection.Find.Replacement.Highlight = True
    Selection.Find.Replacement.Font.Bold = True
    With Selection.Find
        .Text = ChrW(8211)
        '.Replacement.Text =
        .Forward = True
        .Wrap = wdFindContinue
        .Format = True
        .MatchCase = False
        .MatchWholeWord = False
        .MatchByte = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
    Options.DefaultHighlightColorIndex = wdYellow
End Sub

Sub char2014()

    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    Options.DefaultHighlightColorIndex = wdViolet
    Selection.Find.Replacement.Highlight = True
    Selection.Find.Replacement.Font.Bold = True
    With Selection.Find
        .Text = ChrW(8212)
       ' .Replacement.Text = "?a"
        .Forward = True
        .Wrap = wdFindContinue
        .Format = True
        .MatchCase = False
        .MatchWholeWord = False
        .MatchByte = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
    Options.DefaultHighlightColorIndex = wdYellow
End Sub


Sub italic_red()

    Selection.Find.ClearFormatting
    Selection.Find.Font.Italic = True
    Selection.Find.Replacement.ClearFormatting
    With Selection.Find.Replacement.Font
        .Bold = True
        .Italic = True
        .Color = wdColorRed
    End With
    With Selection.Find
        .Text = ""
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        .Format = True
        .MatchCase = False
        .MatchWholeWord = False
        .MatchByte = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
End Sub

Sub sub_blue()

    
    Selection.Find.ClearFormatting
    With Selection.Find.Font
        .Subscript = True
    End With
    Selection.Find.Replacement.ClearFormatting
    Options.DefaultHighlightColorIndex = wdBrightGreen
    Selection.Find.Replacement.Highlight = True
    With Selection.Find
        .Text = ""
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        .Format = True
        .MatchCase = False
        .MatchWholeWord = False
        .MatchByte = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
    Options.DefaultHighlightColorIndex = wdYellow
End Sub

Sub sup_green()

    
    Selection.Find.ClearFormatting
    With Selection.Find.Font
        .Superscript = True
    End With
    Selection.Find.Replacement.ClearFormatting
    Options.DefaultHighlightColorIndex = wdTurquoise
    Selection.Find.Replacement.Highlight = True
    With Selection.Find
        .Text = ""
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        .Format = True
        .MatchCase = False
        .MatchWholeWord = False
        .MatchByte = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
    Options.DefaultHighlightColorIndex = wdYellow
End Sub

Sub underline_orange()

    Selection.Find.ClearFormatting
    Selection.Find.Font.Underline = wdUnderlineSingle
    Selection.Find.Replacement.ClearFormatting
    With Selection.Find.Replacement.Font
        .Bold = True
        .Color = -654262273
        .Underline = wdUnderlineSingle
    End With
    With Selection.Find
        .Text = ""
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        .Format = True
        .MatchCase = False
        .MatchWholeWord = False
        .MatchByte = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
End Sub

Sub highlight_bold_space()

    Selection.Find.ClearFormatting
    Selection.Find.Font.Bold = True
    Selection.Find.Replacement.ClearFormatting
    Selection.Find.Replacement.Highlight = True
    Selection.Find.Replacement.Font.Bold = True
    With Selection.Find
        .Text = " "
        .Replacement.Text = " "
        .Forward = True
        .Wrap = wdFindContinue
        .Format = True
        .MatchCase = False
        .MatchWholeWord = False
        .MatchByte = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
        
End Sub
Sub highlight_sup_space()

    Selection.Find.ClearFormatting
    With Selection.Find.Font
        .Superscript = True
    End With
    Selection.Find.Replacement.ClearFormatting
    Selection.Find.Replacement.Highlight = True
    With Selection.Find
        .Text = " "
        .Replacement.Text = " "
        .Forward = True
        .Wrap = wdFindContinue
        .Format = True
        .MatchCase = False
        .MatchWholeWord = False
        .MatchByte = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
        
End Sub
Sub highlight_sub_space()

    Selection.Find.ClearFormatting
    With Selection.Find.Font
        .Subscript = True
    End With
    Selection.Find.Replacement.ClearFormatting
    Selection.Find.Replacement.Highlight = True
    With Selection.Find
        .Text = " "
        .Replacement.Text = " "
        .Forward = True
        .Wrap = wdFindContinue
        .Format = True
        .MatchCase = False
        .MatchWholeWord = False
        .MatchByte = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
        
End Sub

Sub section_highlight()

    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    Selection.Find.Replacement.Highlight = True
    With Selection.Find
        .Text = "Section"
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        .Format = True
        .MatchCase = False
        .MatchWholeWord = False
        .MatchByte = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
        
End Sub
Sub nd_highlight()

    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    Selection.Find.Replacement.Highlight = True
    With Selection.Find
        .Text = "n.d."
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        .Format = True
        .MatchCase = False
        .MatchWholeWord = False
        .MatchByte = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
        
End Sub
Sub forthcome_highlight()

    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    Selection.Find.Replacement.Highlight = True
    With Selection.Find
        .Text = "forthcoming"
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        .Format = True
        .MatchCase = False
        .MatchWholeWord = False
        .MatchByte = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
        
End Sub

Sub Appendix_highlight()

    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    Selection.Find.Replacement.Highlight = True
    With Selection.Find
        .Text = "Appendi"
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        .Format = True
        .MatchCase = False
        .MatchWholeWord = False
        .MatchByte = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
        
End Sub
Sub Chart_highlight()

    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    Selection.Find.Replacement.Highlight = True
    With Selection.Find
        .Text = "Chart"
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        .Format = True
        .MatchCase = False
        .MatchWholeWord = False
        .MatchByte = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
        
End Sub
Sub Box_highlight()

    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    Selection.Find.Replacement.Highlight = True
    With Selection.Find
        .Text = "Box"
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        .Format = True
        .MatchCase = False
        .MatchWholeWord = False
        .MatchByte = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
        
End Sub
Sub supplement_highlight()

    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    Selection.Find.Replacement.Highlight = True
    With Selection.Find
        .Text = "Supplement"
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        .Format = True
        .MatchCase = False
        .MatchWholeWord = False
        .MatchByte = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    
    Selection.Find.Execute Replace:=wdReplaceAll
        
End Sub


Sub figure_highlight()

    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    Selection.Find.Replacement.Highlight = True
    With Selection.Find
        .Text = "Figure"
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        .Format = True
        .MatchCase = False
        .MatchWholeWord = False
        .MatchByte = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
        
End Sub

Sub table_highlight()

    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    Selection.Find.Replacement.Highlight = True
    With Selection.Find
        .Text = "Table"
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        .Format = True
        .MatchCase = False
        .MatchWholeWord = False
        .MatchByte = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
        
End Sub
Sub scheme_highlight()

    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    Selection.Find.Replacement.Highlight = True
    With Selection.Find
        .Text = "Scheme"
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        .Format = True
        .MatchCase = False
        .MatchWholeWord = False
        .MatchByte = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
        
End Sub

Sub www_highlight()

    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    Selection.Find.Replacement.Highlight = True
    With Selection.Find
        .Text = "www"
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        .Format = True
        .MatchCase = True
        .MatchWholeWord = False
        .MatchByte = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
        
End Sub

Sub http_highlight()

    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    Selection.Find.Replacement.Highlight = True
    With Selection.Find
        .Text = "http"
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        .Format = True
        .MatchCase = True
        .MatchWholeWord = False
        .MatchByte = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
        
End Sub

Sub save_filtered_html()

ChangeFileOpenDirectory ActiveDocument.Path

    With ActiveDocument.WebOptions
        .RelyOnCSS = True
        .OptimizeForBrowser = True
        .OrganizeInFolder = True
        .UseLongFileNames = True
        .RelyOnVML = False
        .AllowPNG = True
        .ScreenSize = msoScreenSize800x600
        .PixelsPerInch = 480
        .Encoding = msoEncodingUTF8
    End With
        
    With Application.DefaultWebOptions
        .UpdateLinksOnSave = True
        .SaveNewWebPagesAsWebArchives = False
    End With
    
    ActiveDocument.SaveAs filename:= _
        "forMerrin.htm", FileFormat:= _
        wdFormatFilteredHTML, LockComments:=False, Password:="", AddToRecentFiles _
        :=True, WritePassword:="", ReadOnlyRecommended:=False, EmbedTrueTypeFonts _
        :=False, SaveNativePictureFormat:=False, SaveFormsData:=False, _
        SaveAsAOCELetter:=False
       
End Sub
Sub conflicts_of_interest()
' make acknowledgements as 1st level
    With Selection.Find
        .Text = "Conflicts of Interest"
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        .Format = False
        .MatchCase = False
        .MatchWholeWord = False
        .MatchByte = True
        .MatchWildcards = True
        .MatchSoundsLike = False
        .MatchAllWordForms = False
        .Execute
        If .Found = True Then
            Selection.HomeKey UNIT:=wdLine
            Selection.Style = ActiveDocument.Styles("_4_heading_1")
            Selection.MoveDown UNIT:=wdParagraph, count:=1
        End If
    End With
    With Selection.Find
        .Text = "Conflict of Interest"
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        .Format = False
        .MatchCase = False
        .MatchWholeWord = False
        .MatchByte = True
        .MatchWildcards = True
        .MatchSoundsLike = False
        .MatchAllWordForms = False
        .Execute
        If .Found = True Then
            Selection.HomeKey UNIT:=wdLine
            Selection.Style = ActiveDocument.Styles("_4_heading_1")
            Selection.MoveDown UNIT:=wdParagraph, count:=1
        End If
    End With
End Sub
Sub author_contributions()
' make acknowledgements as 1st level
    With Selection.Find
       
        .Text = "Author Contributions"
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        .Format = False
        .MatchCase = False
        .MatchWholeWord = False
        .MatchByte = True
        .MatchWildcards = True
        .MatchSoundsLike = False
        .MatchAllWordForms = False
        .Execute
        If .Found = True Then
            Selection.HomeKey UNIT:=wdLine
            Selection.Style = ActiveDocument.Styles("_4_heading_1")
            Selection.MoveDown UNIT:=wdParagraph, count:=1
        End If
    End With
    
End Sub

Sub import_style()

Dim userName As String
    userName = Environ("Username")
    Application.OrganizerCopy Source:= _
        "C:\Users\" & userName & "\AppData\Roaming\Microsoft\Templates\Normal1.dotm" _
        , Destination:= _
        ActiveDocument.name _
        , name:="_1_article_title", Object:=wdOrganizerObjectStyles
    Application.OrganizerCopy Source:= _
        "C:\Users\" & userName & "\AppData\Roaming\Microsoft\Templates\Normal1.dotm" _
        , Destination:= _
        ActiveDocument.name _
        , name:="_1_article_title", Object:=wdOrganizerObjectStyles
    Application.OrganizerCopy Source:= _
        "C:\Users\" & userName & "\AppData\Roaming\Microsoft\Templates\Normal1.dotm" _
        , Destination:= _
        ActiveDocument.name _
        , name:="_1_article_type", Object:=wdOrganizerObjectStyles
    Application.OrganizerCopy Source:= _
        "C:\Users\" & userName & "\AppData\Roaming\Microsoft\Templates\Normal1.dotm" _
        , Destination:= _
        ActiveDocument.name _
        , name:="_2_author_affiliation", Object:=wdOrganizerObjectStyles
    Application.OrganizerCopy Source:= _
        "C:\Users\" & userName & "\AppData\Roaming\Microsoft\Templates\Normal1.dotm" _
        , Destination:= _
        ActiveDocument.name _
        , name:="_2_author_correspondence", Object:=wdOrganizerObjectStyles
    Application.OrganizerCopy Source:= _
        "C:\Users\" & userName & "\AppData\Roaming\Microsoft\Templates\Normal1.dotm" _
        , Destination:= _
        ActiveDocument.name _
        , name:="_2_author_email", Object:=wdOrganizerObjectStyles
    Application.OrganizerCopy Source:= _
        "C:\Users\" & userName & "\AppData\Roaming\Microsoft\Templates\Normal1.dotm" _
        , Destination:= _
        ActiveDocument.name _
        , name:="_2_author_name", Object:=wdOrganizerObjectStyles
    Application.OrganizerCopy Source:= _
        "C:\Users\" & userName & "\AppData\Roaming\Microsoft\Templates\Normal1.dotm" _
        , Destination:= _
        ActiveDocument.name _
        , name:="_2_academic_editor", Object:=wdOrganizerObjectStyles
    Application.OrganizerCopy Source:= _
        "C:\Users\" & userName & "\AppData\Roaming\Microsoft\Templates\Normal1.dotm" _
        , Destination:= _
        ActiveDocument.name _
        , name:="_3_abstract", Object:=wdOrganizerObjectStyles
    Application.OrganizerCopy Source:= _
        "C:\Users\" & userName & "\AppData\Roaming\Microsoft\Templates\Normal1.dotm" _
        , Destination:= _
        ActiveDocument.name _
        , name:="_3_classifications", Object:=wdOrganizerObjectStyles
    Application.OrganizerCopy Source:= _
        "C:\Users\" & userName & "\AppData\Roaming\Microsoft\Templates\Normal1.dotm" _
        , Destination:= _
        ActiveDocument.name _
        , name:="_3_keywords", Object:=wdOrganizerObjectStyles
    Application.OrganizerCopy Source:= _
        "C:\Users\" & userName & "\AppData\Roaming\Microsoft\Templates\Normal1.dotm" _
        , Destination:= _
        ActiveDocument.name _
        , name:="_3_publication_history", Object:=wdOrganizerObjectStyles
    Application.OrganizerCopy Source:= _
        "C:\Users\" & userName & "\AppData\Roaming\Microsoft\Templates\Normal1.dotm" _
        , Destination:= _
        ActiveDocument.name _
        , name:="_4_heading_1", Object:=wdOrganizerObjectStyles
    Application.OrganizerCopy Source:= _
        "C:\Users\" & userName & "\AppData\Roaming\Microsoft\Templates\Normal1.dotm" _
        , Destination:= _
        ActiveDocument.name _
        , name:="_4_heading_2", Object:=wdOrganizerObjectStyles
    Application.OrganizerCopy Source:= _
        "C:\Users\" & userName & "\AppData\Roaming\Microsoft\Templates\Normal1.dotm" _
        , Destination:= _
        ActiveDocument.name _
        , name:="_4_heading_3", Object:=wdOrganizerObjectStyles
    Application.OrganizerCopy Source:= _
        "C:\Users\" & userName & "\AppData\Roaming\Microsoft\Templates\Normal1.dotm" _
        , Destination:= _
        ActiveDocument.name _
        , name:="_4_heading_4", Object:=wdOrganizerObjectStyles
    Application.OrganizerCopy Source:= _
        "C:\Users\" & userName & "\AppData\Roaming\Microsoft\Templates\Normal1.dotm" _
        , Destination:= _
        ActiveDocument.name _
        , name:="_4_text", Object:=wdOrganizerObjectStyles
    Application.OrganizerCopy Source:= _
        "C:\Users\" & userName & "\AppData\Roaming\Microsoft\Templates\Normal1.dotm" _
        , Destination:= _
        ActiveDocument.name _
        , name:="_4_text_citation", Object:=wdOrganizerObjectStyles
    Application.OrganizerCopy Source:= _
        "C:\Users\" & userName & "\AppData\Roaming\Microsoft\Templates\Normal1.dotm" _
        , Destination:= _
        ActiveDocument.name _
        , name:="_4_disp_quote", Object:=wdOrganizerObjectStyles
    Application.OrganizerCopy Source:= _
        "C:\Users\" & userName & "\AppData\Roaming\Microsoft\Templates\Normal1.dotm" _
        , Destination:= _
        ActiveDocument.name _
        , name:="_4_speaker", Object:=wdOrganizerObjectStyles
    Application.OrganizerCopy Source:= _
        "C:\Users\" & userName & "\AppData\Roaming\Microsoft\Templates\Normal1.dotm" _
        , Destination:= _
        ActiveDocument.name _
        , name:="_4_statement", Object:=wdOrganizerObjectStyles
    Application.OrganizerCopy Source:= _
        "C:\Users\" & userName & "\AppData\Roaming\Microsoft\Templates\Normal1.dotm" _
        , Destination:= _
        ActiveDocument.name _
        , name:="_4_text_float_citation", Object:=wdOrganizerObjectStyles
    Application.OrganizerCopy Source:= _
        "C:\Users\" & userName & "\AppData\Roaming\Microsoft\Templates\Normal1.dotm" _
        , Destination:= _
        ActiveDocument.name _
        , name:="_4_text_list", Object:=wdOrganizerObjectStyles
        
        
    Application.OrganizerCopy Source:= _
        "C:\Users\" & userName & "\AppData\Roaming\Microsoft\Templates\Normal1.dotm" _
        , Destination:= _
        ActiveDocument.name _
        , name:="_5_table_body", Object:=wdOrganizerObjectStyles



    Application.OrganizerCopy Source:= _
        "C:\Users\" & userName & "\AppData\Roaming\Microsoft\Templates\Normal1.dotm" _
        , Destination:= _
        ActiveDocument.name _
        , name:="_5_table_caption", Object:=wdOrganizerObjectStyles
    Application.OrganizerCopy Source:= _
        "C:\Users\" & userName & "\AppData\Roaming\Microsoft\Templates\Normal1.dotm" _
        , Destination:= _
        ActiveDocument.name _
        , name:="_5_table_footer", Object:=wdOrganizerObjectStyles
    Application.OrganizerCopy Source:= _
        "C:\Users\" & userName & "\AppData\Roaming\Microsoft\Templates\Normal1.dotm" _
        , Destination:= _
        ActiveDocument.name _
        , name:="_5_table_header", Object:=wdOrganizerObjectStyles
    Application.OrganizerCopy Source:= _
        "C:\Users\" & userName & "\AppData\Roaming\Microsoft\Templates\Normal1.dotm" _
        , Destination:= _
        ActiveDocument.name _
        , name:="_5_table_wrap_foot", Object:=wdOrganizerObjectStyles
    Application.OrganizerCopy Source:= _
        "C:\Users\" & userName & "\AppData\Roaming\Microsoft\Templates\Normal1.dotm" _
        , Destination:= _
        ActiveDocument.name _
        , name:="_6_figure_body", Object:=wdOrganizerObjectStyles
    Application.OrganizerCopy Source:= _
        "C:\Users\" & userName & "\AppData\Roaming\Microsoft\Templates\Normal1.dotm" _
        , Destination:= _
        ActiveDocument.name _
        , name:="_6_figure_caption", Object:=wdOrganizerObjectStyles
    Application.OrganizerCopy Source:= _
        "C:\Users\" & userName & "\AppData\Roaming\Microsoft\Templates\Normal1.dotm" _
        , Destination:= _
        ActiveDocument.name _
        , name:="_7_text_equation", Object:=wdOrganizerObjectStyles
    Application.OrganizerCopy Source:= _
        "C:\Users\" & userName & "\AppData\Roaming\Microsoft\Templates\Normal1.dotm" _
        , Destination:= _
        ActiveDocument.name _
        , name:="_7_box_caption", Object:=wdOrganizerObjectStyles
    Application.OrganizerCopy Source:= _
        "C:\Users\" & userName & "\AppData\Roaming\Microsoft\Templates\Normal1.dotm" _
        , Destination:= _
        ActiveDocument.name _
        , name:="_7_box_title", Object:=wdOrganizerObjectStyles
    Application.OrganizerCopy Source:= _
        "C:\Users\" & userName & "\AppData\Roaming\Microsoft\Templates\Normal1.dotm" _
        , Destination:= _
        ActiveDocument.name _
        , name:="_7_box_text", Object:=wdOrganizerObjectStyles
    Application.OrganizerCopy Source:= _
        "C:\Users\" & userName & "\AppData\Roaming\Microsoft\Templates\Normal1.dotm" _
        , Destination:= _
        ActiveDocument.name _
        , name:="_8_notes", Object:=wdOrganizerObjectStyles
    Application.OrganizerCopy Source:= _
        "C:\Users\" & userName & "\AppData\Roaming\Microsoft\Templates\Normal1.dotm" _
        , Destination:= _
        ActiveDocument.name _
        , name:="_8_reference", Object:=wdOrganizerObjectStyles
    Application.OrganizerCopy Source:= _
        "C:\Users\" & userName & "\AppData\Roaming\Microsoft\Templates\Normal1.dotm" _
        , Destination:= _
        ActiveDocument.name _
        , name:="_9_supplement_caption", Object:=wdOrganizerObjectStyles
    Application.OrganizerCopy Source:= _
        "C:\Users\" & userName & "\AppData\Roaming\Microsoft\Templates\Normal1.dotm" _
        , Destination:= _
        ActiveDocument.name _
        , name:="_9_supplement_filename", Object:=wdOrganizerObjectStyles
    Application.OrganizerCopy Source:= _
        "C:\Users\" & userName & "\AppData\Roaming\Microsoft\Templates\Normal1.dotm" _
        , Destination:= _
        ActiveDocument.name _
        , name:="_9_supplement_filetype", Object:=wdOrganizerObjectStyles

End Sub
Sub table_border_autofit_tablebody()
'
' Macro4 Macro
'
'
    With Selection.Borders(wdBorderTop)
        .LineStyle = Options.DefaultBorderLineStyle
        .LineWidth = Options.DefaultBorderLineWidth
        .Color = Options.DefaultBorderColor
    End With
    With Selection.Borders(wdBorderLeft)
        .LineStyle = Options.DefaultBorderLineStyle
        .LineWidth = Options.DefaultBorderLineWidth
        .Color = Options.DefaultBorderColor
    End With
    With Selection.Borders(wdBorderBottom)
        .LineStyle = Options.DefaultBorderLineStyle
        .LineWidth = Options.DefaultBorderLineWidth
        .Color = Options.DefaultBorderColor
    End With
    With Selection.Borders(wdBorderRight)
        .LineStyle = Options.DefaultBorderLineStyle
        .LineWidth = Options.DefaultBorderLineWidth
        .Color = Options.DefaultBorderColor
    End With
    With Selection.Borders(wdBorderHorizontal)
        .LineStyle = Options.DefaultBorderLineStyle
        .LineWidth = Options.DefaultBorderLineWidth
        .Color = Options.DefaultBorderColor
    End With
    With Selection.Borders(wdBorderVertical)
        .LineStyle = Options.DefaultBorderLineStyle
        .LineWidth = Options.DefaultBorderLineWidth
        .Color = Options.DefaultBorderColor
    End With
    Selection.Tables(1).AutoFitBehavior (wdAutoFitContent)
    Selection.Style = ActiveDocument.Styles("_5_table_body")
    
End Sub




Sub set_table_body()



Selection.HomeKey wdStory
 With Selection.Find
            .ClearFormatting
           .Text = "Table "
           .Font.Bold = True
           .MatchWildcards = True
           .Forward = True
            .Wrap = wdFindStop
            .Replacement.Text = ""
            Do
            .Execute
            If .Found Then
            If Asc(Selection.Range.Previous) = 13 And Selection.Range.ParagraphFormat.SpaceBefore = 24 Then
                Selection.MoveDown UNIT:=wdParagraph, count:=1
                'Selection.Tables(1).Range.Select
                  If Selection.Style <> ActiveDocument.Styles("_5_table_body") Then
                  Selection.Tables(1).Range.Style = ActiveDocument.Styles("_5_table_body")
                  Selection.MoveRight UNIT:=wdCharacter, count:=1
                  End If
                
                Else
                 Selection.MoveRight UNIT:=wdCharacter, count:=1
            End If
            
            Else
            
           Exit Do
            End If
            
            Loop
            
        End With

End Sub

Sub dsasa()
Selection.Style = ActiveDocument.Styles("_3_keywords")
End Sub


Sub set_text_kr()

Dim d As Document
    Set d = ActiveDocument
    d.Paragraphs(1).Style = ActiveDocument.Styles("_4_text")
    With d.Range(d.Paragraphs(2).Range.Start, d.Paragraphs(2).Range.Start + 1) '用With结构定义了一个指针变量并初始化指向文档首,也可以定义一个指针变量Dim p as Range
        Do While .End < d.Content.End - 1 '如果指针指向的地址不是文档尾部的地址,那么进入循环
            If .Information(12) And InStr(.Previous(wdParagraph, 1), "Table ") = 1 Then  '如果指针指向的地址为表格的首地址,那么:
                .Expand 15: .Move       '指针跳过整个表格而指向该表格之后的段落首地址
            
            Else
       
        
        
        .Paragraphs(1).Range.Style = ActiveDocument.Styles("_4_text")
           
         .Move 4
      End If
      
        Loop                                      '循环到Do开始
    End With
End Sub



Sub das()
    Dim d As Document
    Set d = ActiveDocument
    d.Paragraphs(1).Style = ActiveDocument.Styles("_4_text")
    With d.Range(d.Paragraphs(2).Range.Start, d.Paragraphs(2).Range.Start + 1) '用With结构定义了一个指针变量并初始化指向文档首,也可以定义一个指针变量Dim p as Range
        Do While .End < d.Content.End - 1 '如果指针指向的地址不是文档尾部的地址,那么进入循环
            If .Information(12) And InStr(.Previous(wdParagraph, 1), "Table ") = 1 Then  '如果指针指向的地址为表格的首地址,那么:
                .Expand 15: .Move       '指针跳过整个表格而指向该表格之后的段落首地址
            
            Else
       
        
        
        .Paragraphs(1).Range.Style = ActiveDocument.Styles("_4_text")
           
         .Move 4
     
       End If
        Loop                                      '循环到Do开始
    End With
End Sub