运行时错误'450'使用Selection.Find在Excel VBA中的Word Doc上

时间:2017-10-03 15:54:16

标签: vba excel-vba word-vba excel

我正在尝试在word文档上选择一个占位符来粘贴剪贴板(我已将excel表复制到其中),但是在粘贴之前很难选择该单词。在Run-time error '450': Wrong number of arguments or invalid property assignment上获取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

我对Word VBA有很多经验,但是从Excel到Word(或PowerPoint)工作我遇到了一连串的错误。

1 个答案:

答案 0 :(得分:1)

继续发布我的解决方案(在@ HarassedDad建议使用书签之后):

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

比我之前尝试的要简单得多。