表格已完成作为附件发送为空白

时间:2016-02-24 11:36:37

标签: excel vba excel-vba

我在Excel中设计了一个表单,供用户填写并点击提交。然后,这应该自动将完成的表单作为附件发送到指定的Outlook电子邮件地址。

我遇到的问题是

  1. 发送一张空白表格。该表单将由公司内的多个用户使用,并将从共享驱动器访问。

  2. 用户无法判断提交按钮是否有效,因为它没有显示任何消息。我想显示一条消息"您的表单现已提交"

  3. 这是我目前的代码

    .js

1 个答案:

答案 0 :(得分:0)

试试这个的一些变化:)

 Private Declare Function ShellExecute Lib "shell32.dll" _
 Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, _
 ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, _
 ByVal nShowCmd As Long) As Long

 sub nameofsub()

 Dim Email As String, Subj As String
 Dim answer As Integer
 Dim Msg As String, body As String, URL As String
 Dim OutApp As Object, OutMail As Object
 Dim filelocation1 As String
 Dim wb1 as workbook

 filelocation1 = "Filepath" & "\" & "filename" & ".filextension"
 CreateObject("Scripting.FileSystemObject").FileExists(filelocation1)

 'code to tell user form how to store information in the document
 'Example: (assuming you use excel as a format)
 'Set wb1 = Workbooks.open(filelocation1)
 ' wb1.worksheet.range("a1").value = textbox1.value     this might be off, double check. this might drastically differ is you use other file extensions 


 Email = "personMcDude@someaddress.com"
 Subj = "My email to you"
 body = "Hello Person," & vbCr & _
         "the stuff is in the folder" & vbCr & _
         "stuff" & vbCr & _
         "more stuff" & vbCr & _
         "and yet more" & vbCr & _
         "Thank you. "

 Set OutApp = CreateObject("Outlook.Application")
 Set OutMail = OutApp.CreateItem(0)

 On Error Resume Next
     With OutMail
         .To = Email
         .CC = vbNullString
         .BCC = vbNullString
         .Subject = Subj
         .body = body
         .Display
     End With
 On Error GoTo 0

 Set OutMail = Nothing
 Set OutApp = Nothing


 End Sub