dwirony
dwirony

Reputation: 5450

Run-time error '450' Using Selection.Find on a Word Doc in Excel VBA

I am attempting to select a placeholder on a word document to paste the clipboard (which I've copied an excel table to), but am having a hard time selecting that word before pasting. Getting Run-time error '450': Wrong number of arguments or invalid property assignment on line With Selection.Find:

ActiveDocument.Content.Select

With Selection.Find '<- Error
    .ClearFormatting
    .Text = "TablePlaceHolder1"
End With

If Selection.Find.Found = True Then
    Selection.Select
End If

ActiveDocument.Range.Paste

I have a ton of experience with Word VBA, but working from Excel into Word (or PowerPoint) I've been running into a flurry of errors.

Upvotes: 1

Views: 968

Answers (1)

dwirony
dwirony

Reputation: 5450

Going to go ahead and post my solution (after @HarassedDad's advice to use a bookmark instead):

With WordApp
    .Selection.Goto What:=wdGoToBookmark, Name:="TablePlaceHolder3"
    .Selection.Paste
End With

Much simpler than what I was attempting before.

Upvotes: 1

Related Questions