Home > Mobile >  Error 450 Wrong number of arguments or invalid property assignment on vba
Error 450 Wrong number of arguments or invalid property assignment on vba

Time:05-11

I want to select a specific word in a .docx using vba excel and then replace it by a BookMark, to do it i want to select the word so i have this code

With word_fichier
        With Selection.Find
            .Forward = True
            .ClearFormatting
            .MatchWholeWord = True
            .MatchCase = False
            .Wrap = wdFindContinue
            .Execute FindText:="#tableauxvdd"
        End With
End With

But i have the 450 error.

CodePudding user response:

Your Selection refers to Excel not Word as you didn't qualify it. You can use:

    With word_fichier.Application.Selection.Find
        .Forward = True
        .ClearFormatting
        .MatchWholeWord = True
        .MatchCase = False
        .Wrap = wdFindContinue
        .Execute FindText:="#tableauxvdd"
    End With

assuming word_fichier was a Document variable.

  • Related