Vba 移动到另一文档中的下一个单元格
在另一文档Vba 移动到另一文档中的下一个单元格,vba,ms-word,word-2007,word-2003,Vba,Ms Word,Word 2007,Word 2003,在另一文档TCN.docx的范围内工作时,我在rng.MoveRight单元:=单元格位置上发现了方法错误或未找到数据成员 Sub TNC() Dim odoc As Document Dim rng As Word.Range Set odoc = Documents.Open(filename:="C:\Users\Bilal\Desktop\TCN.docx", Visible:=True) Set rng = odoc.Content rng.Find.Clea
TCN.docx
的范围内工作时,我在rng.MoveRight单元:=单元格
位置上发现了方法错误或未找到数据成员
Sub TNC()
Dim odoc As Document
Dim rng As Word.Range
Set odoc = Documents.Open(filename:="C:\Users\Bilal\Desktop\TCN.docx", Visible:=True)
Set rng = odoc.Content
rng.Find.ClearFormatting
rng.Find.Font.Bold = True
With rng.Find
.Text = "BU"
.Forward = True
.Wrap = wdFindStop
.Format = True
End With
rng.Find.Execute
If rng.Find.Found = True Then
rng.MoveRight unit:=Cell **ERROR position**
rng.COPY
Else
End If
odoc.Close wdDoNotSaveChanges
Selection.PasteAndFormat (wdPasteDefault)
End Sub
为了更好地理解
编辑:辛迪·迈斯特编辑问题后
MoveRight
对于Range
对象无效,而对于Selection
对象无效
对于unit
枚举,没有Cell
值,而wdCell
是
要将元素复制到找到的单元格的右侧,请使用
...
rng.Find.Execute
If rng.Find.Found = True Then
rng.Select
Selection.MoveRight unit:=wdCell
Selection.Copy
Else
End If
...