情况是我已经从Google chrome复制了文本,现在我需要将此文本用作Word文档中的字符串SWORD
至Find
。我不知道如何处理复制的文本。
有一种间接的方法,我可以使用Selection.Paste
粘贴文本,然后选择它作为string
。我正在寻找直接方法,它花费了很多额外的时间。请帮忙!
SWORD = '''''''Copied text
Set doc = Application.Windows("Ticker Graveyard").Document
Set rng = doc.Content
With rng.Find
.Text = SWORD
.Forward = True
.Wrap = wdFindContinue
.MatchWildcards = False
.MatchWholeWord = True
.Execute
End With
已更新的问题答案:
Dim DataObj As New MSForms.DataObject
DataObj.GetFromClipboard
SWORD = DataObj.GetText
Set doc = Application.Windows("Ticker Graveyard").Document
Set rng = doc.Content
With rng.Find
.Text = SWORD
.Forward = True
.Wrap = wdFindContinue
.MatchWildcards = False
.MatchWholeWord = True
.Execute
End With