Mrrrr's Forum (VIEW ONLY)
Un forum care ofera solutii pentru unele probleme legate in general de PC. Pe langa solutii, aici puteti gasi si alte lucruri interesante // A forum that offers solutions to some PC related issues. Besides these, here you can find more interesting stuff.
Lista Forumurilor Pe Tematici
Mrrrr's Forum (VIEW ONLY) | Reguli | Inregistrare | Login

POZE MRRRR'S FORUM (VIEW ONLY)

Nu sunteti logat.
Nou pe simpatie:
Kalifa
Femeie
19 ani
Ialomita
cauta Barbat
19 - 32 ani
Mrrrr's Forum (VIEW ONLY) / Tutoriale si Ghiduri Utile // Tutorials and useful guides / [WORD] Delete Paragraph if its Shading is RGB [VBA] Moderat de TRaP, TonyTzu
Autor
Mesaj Pagini: 1
TRaP
Moderator

Inregistrat: acum 6 ani
Postari: 748
The following code deletes entire paragraphs in the active document that have the RGB: 184,221,241 color shading.
You can replace the values in RGB with your own.

Just open VBA from Word, make new module and paste the following:


Sub DeleteParagraphIfShading()
    Application.ScreenUpdating = False

Dim para As Paragraph
    For Each para In ActiveDocument.Paragraphs
   
    On Error Resume Next

        If para.Range.Shading.BackgroundPatternColor = RGB(184, 221, 241) Then
            para.Range.Delete
        End If
       
    Next

    Application.ScreenUpdating = True
End Sub


Modificat de TRaP (acum 5 ani)


pus acum 5 ani
   
TRaP
Moderator

Inregistrat: acum 6 ani
Postari: 748
If you want, for example to shrink the text of a paragraph, you insert the following snippet inside the For function above:

    If para.Range.Shading.BackgroundPatternColor = RGB(255, 250, 250) Then
        para.Range.Font.Size = 5
    End If


pus acum 5 ani
   
TRaP
Moderator

Inregistrat: acum 6 ani
Postari: 748
Made a user form with 2 buttons, one called Dark Blue and another one called Lite Blue.

Command button 1 and 2 click takes you to:


Private Sub CommandButton1_Click()
Application.ScreenUpdating = False

Dim para As Paragraph

For Each para In ActiveDocument.Paragraphs
On Error Resume Next
    If para.Range.Shading.BackgroundPatternColor = RGB(184, 221, 241) Then
        para.Range.Delete
    End If
Next

Application.ScreenUpdating = True
End Sub

Private Sub CommandButton2_Click()
Application.ScreenUpdating = False

Dim para As Paragraph

For Each para In ActiveDocument.Paragraphs
On Error Resume Next
    If para.Range.Shading.BackgroundPatternColor = RGB(230, 249, 255) Then
        para.Range.Delete
    End If
Next

Application.ScreenUpdating = True
End Sub


Calling User Form with macro:


Sub ParagDeleteForm()
    ParagraphDeleteForm.Show
End Sub


Modificat de TRaP (acum 5 ani)


pus acum 5 ani
   
Pagini: 1  

Mergi la