• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

VBA Code to add data from User form

hayden_pinto

New Member
Hi


I have prepared a user form with some drop downs

as below - i have also

Drop downs in the user form

Label2.Caption

ComboBox2.Text

ComboBox1.Text

ComboBox3.Text

Label8.Caption

ComboBox5.Text

Label14.Caption


Outlook script (Module1)


Sub outlook_1(FilePath As String) 'Related to sending the file to the specified email address

Dim out_app As Outlook.Application

Dim out_mail As Outlook.MailItem

Set out_app = CreateObject("Outlook.Application")

Set out_mail = out_app.CreateItem(olMailItem)

out_mail.Subject = "Notification"

out_mail.Body = "The record has been successfully submitted by " & UNameWindows & " at " & Time_Submitted & " ." <<THIS IS WHERE I WANT TO ADD ALL THE DROP DOWN BOX DATA SELECTED >>

out_mail.Attachments.Add FilePath

out_mail.Recipients.Add "x@x.com"

On Error Resume Next

out_mail.Send

End Sub


Function UNameWindows() As String ' To get the username

UNameWindows = Environ("USERNAME")

End Function


Function Time_Submitted() As String

Time_Submitted = Format(Now(), "hh:mm:ss")

End Function


<<Whats do i have to add in this code to have the data that is selected in the drop down box's in the Userform added to the mail.>>
 
Hi, hayden_pinto!


I don't see any reference to adding the user form to the mail.


If it's just the data of the controls, tried replacing your "<< ... >>" by this (both unquoted)?

"& VbCr & UserFormXXXX.Label2.Caption & VbCr & UserFormXXXX.ComboBox2.text & VbCr & UserFormXXXX.ComboBox1.text & VbCr & UserFormXXXX.ComboBox3.text & VbCr & UserFormXXXX.ComboBox2.text & UserFormXXXX.Label8.Caption & VbCr & UserFormXXXX.ComboBox5.text & UserFormXXXX.Label4.Caption"


Otherwise, please consider uploading a sample file.


Regards
 
Hi, hayden_pinto!

Glad you solved it. Thanks for your feedback and welcome back whenever needed or wanted.

Regards!
 
Back
Top