我将数据从一个文档移动到另一个文档。我需要移动数据并将其作为字符串。我只是不知道如何把它放在另一个word文档中。
以下是获取文字。
'finds a range of text between the words "Purpose" and "Scope" and makes it strThePurpose
Application.ScreenUpdating = False
Selection.HomeKey wdStory
Selection.Find.Text = "Purpose"
blnFound = Selection.Find.Execute
If blnFound Then
Selection.MoveLeft wdWord
Set rng1 = Selection.Range
Selection.Find.Text = "Scope" 'changed here 2014-18-04 from "7.0 Revisions:" to "Revisions:"
blnFound = Selection.Find.Execute
If blnFound Then
Set rng2 = Selection.Range
Set rngFound = ActiveDocument.Range(rng1.Start, rng2.Start)
strThePurposeText = rngFound
'MsgBox (strTheText)
End If
End If
我只是不知道如何将它放在模板文件中特定行的word文档中。
答案似乎有效:
Selection.GoTo What:=wdGoToLine, Which:=wdGoToFirst, Count:=7, Name:=""
Selection.TypeText Text:=strTheRefDocsText
更好更有效的方法是在单词中插入书签并在书签中插入单词模板。
Selection.GoTo What:=wdGoToBookmark, Name:="bmBeginningOfDocument"
Selection.PasteAndFormat (wdPasteDefault)
答案 0 :(得分:0)
Selection.GoTo What:=wdGoToBookmark, Name:="bmBeginningOfDocument"
Selection.PasteAndFormat (wdPasteDefault)
我使用上面的代码更好地了解如何到达该位置。