我有一个锁定的Word表单,只有用户可以填写的字段.当它们到达结尾时,有一个提交按钮,它是一个活动的x控件,代码如下:
Private Sub CommandButton1_Click()
Dim bStarted As Boolean
Dim oOutlookApp As Outlook.Application
Dim oItem As Outlook.MailItem
On Error Resume Next
If Len(ActiveDocument.Path) = 0 Then
MsgBox "Document needs to be saved first"
Exit Sub
End If
Set oOutlookApp = GetObject(, "Outlook.Application")
If Err <> 0 Then
Set oOutlookApp = CreateObject("Outlook.Application")
bStarted = True
End If
Set oItem = oOutlookApp.CreateItem(olMailItem)
With oItem
.To = "email address"
.Subject = "New subject"
'Add the document as an attachment, you can use the .displayname …Run Code Online (Sandbox Code Playgroud)