Inlocuire

Închis
Apostolu
Mesaje: 285
Membru din: Joi Aug 20, 2009 4:05 pm

Inlocuire

Mesaj de Apostolu » Joi Oct 01, 2015 7:02 am

Acest script modifica doar "(5) î" in "(5) Î". (litera mica in litera mare)
Intre paranteze pot insa sa fie doua sau mai multe cifre .... "(55) î"
Cum se poatre modifica ?

Multumesc.

Cod: Selectaţi tot

Sub CapAfterRoundbracket()
    With ActiveDocument.Range.Find
        .ClearFormatting
        With .Replacement.Font
            .SmallCaps = False
            .AllCaps = True
        End With

        .MatchWildcards = True
        .Text = "([(][0-9][)]) ([î])"
        .Replacement.Text = "\1 \2"
        .Execute Replace:=wdReplaceAll
    End With

End Sub
Ultima oară modificat Vin Oct 02, 2015 7:11 pm de către Dr.Windows, modificat 1 dată în total.
Motiv: Adaugare taguri CODE

Dr.Windows
Moderator
Moderator
Mesaje: 4570
Membru din: Vin Iul 31, 2009 7:32 am

Re: Inlocuire

Mesaj de Dr.Windows » Vin Oct 02, 2015 7:52 pm

Daca vrei sa modifici dupa urmatorul model: "(n) (i)" unde "n" reprezinta unul sau mai multe cifre, atunci in loc de sablonul ([0-9]) ar trebui sa folosesti ([0-9]{1,3}) unde intervalul {1,3} reprezinta intervalul de "repetitii" pentru acele numere - adica de la minim 1 la maxim 3.
Atentie, nu uita ca daca vrei sa cauti parantezele rotunde sirul de cautat ar trebui sa fie "\(", mai exact, in cazul tau "patternul" de cautat ar fi: "(\([0-9]{1,3}\)) (\(i\))"

Apostolu
Mesaje: 285
Membru din: Joi Aug 20, 2009 4:05 pm

Re: Inlocuire

Mesaj de Apostolu » Sâm Oct 03, 2015 5:00 am

Multumesc.
O sa verific cum merge.

Apostolu
Mesaje: 285
Membru din: Joi Aug 20, 2009 4:05 pm

Re: Inlocuire

Mesaj de Apostolu » Sâm Oct 03, 2015 6:05 am

Am modificat.
Nu da eroare dar, nici nun face nimic !

Cod: Selectaţi tot

Sub CapAfterRoundbracket2()
    With ActiveDocument.Range.Find
        .ClearFormatting
        With .Replacement.Font
            .SmallCaps = False
            .AllCaps = True
        End With

        .MatchWildcards = True
        .Text = "(\([0-9]{1,3}\)) (\(î\))"
        .Replacement.Text = "\1 \2"
        .Execute Replace:=wdReplaceAll
    End With

End Sub
Ultima oară modificat Sâm Oct 10, 2015 2:05 pm de către Dr.Windows, modificat 1 dată în total.
Motiv: Adaugare taguri CODE

Apostolu
Mesaje: 285
Membru din: Joi Aug 20, 2009 4:05 pm

Re: Inlocuire

Mesaj de Apostolu » Joi Oct 08, 2015 12:14 pm

Dr. Windows,

Am dibuit-o, pana la urma, eu. ! :)
Asa e corect:

Cod: Selectaţi tot

Sub CapAfterRoundbracket()

    '(5)î cu (5)Î
    
    With ActiveDocument.Range.Find
        .ClearFormatting
        With .Replacement.Font
            .SmallCaps = False
            .AllCaps = True
        End With

        .MatchWildcards = True
        .Text = "([(][0-9]{1,}[)]) ([î])"
        .Replacement.Text = "\1 \2"
        .Execute Replace:=wdReplaceAll
    End With

End Sub
Ultima oară modificat Sâm Oct 10, 2015 2:05 pm de către Dr.Windows, modificat 1 dată în total.
Motiv: Adaugare taguri CODE

Închis

Înapoi la “Visual Basic for Application (VBA) - Intrebari tehnice”