请把下面的代码复制到模板文件的模块下
Sub getCode()
Dim code As String
With Selection
.StartIsActive = False
.Extend Character:=")"
End With
If Selection.Fields().Count > 0 Then
Clipboard_SetText Selection.Fields(1).code
Else
Clipboard_SetText ""
End If
End Sub
这个函数,也要加进去
Public Sub Clipboard_SetText(sInput As String)
On Error GoTo Error_Handler
With CreateObject("new:{1C3B4210-F441-11CE-B9EA-00AA006B1A69}")
.SetText sInput
.PutInClipboard
Error_Handler_Exit:
On Error Resume Next
Exit Sub
Error_Handler:
MsgBox "The following error has occurred" & vbCrLf & vbCrLf & _
"Error Number: " & Err.Number & vbCrLf & _
"Error Source: Clipboard_SetText" & vbCrLf & _
"Error Description: " & Err.Description & _
Switch(Erl = 0, "", Erl <> 0, vbCrLf & "Line No: " & Erl) _
, vbOKOnly + vbCritical, "An Error has Occurred!"
Resume Error_Handler_Exit