Skip to content

Instantly share code, notes, and snippets.

@wyfinger
Last active August 29, 2015 14:20
Show Gist options
  • Save wyfinger/24d9cc403ce8f902c885 to your computer and use it in GitHub Desktop.
Save wyfinger/24d9cc403ce8f902c885 to your computer and use it in GitHub Desktop.
VBA, Word. Копирование кода поля в буфер
Sub CopyFieldCode()
'
' Копирование кода поля в буфер
'
Dim sFieldCode As String
Dim d As Object
If Selection.Fields.Count = 0 Then Exit Sub
sFieldCode = "{" & Replace(Replace(Selection.Fields(1).Code, ChrW(19), "{"), ChrW(21), "}") & "}"
Set d = GetObject("New:{1C3B4210-F441-11CE-B9EA-00AA006B1A69}")
d.SetText (sFieldCode)
d.PutInClipboard
Set d = Nothing
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment