+ Reply to Thread
Results 1 to 8 of 8

Userform prepopulate email

Hybrid View

EagleInsight Userform prepopulate email 01-15-2014, 06:49 PM
Tinbendr Re: Userform prepopulate email 01-15-2014, 08:43 PM
event21 Re: Userform prepopulate email 01-15-2014, 08:50 PM
EagleInsight Re: Userform prepopulate email 01-16-2014, 09:52 AM
Tinbendr Re: Userform prepopulate email 01-16-2014, 10:27 AM
EagleInsight Re: Userform prepopulate email 01-16-2014, 11:01 AM
Tinbendr Re: Userform prepopulate email 01-16-2014, 04:16 PM
EagleInsight Re: Userform prepopulate email 01-22-2014, 08:16 PM
  1. #1
    Registered User
    Join Date
    01-09-2014
    Location
    New York
    MS-Off Ver
    Excel 2003
    Posts
    15

    Userform prepopulate email

    I have a userform that i want to use to prepopulate an email. However when i click the button at the email, i get a "user definted.." error message.

    Please can you help in check the error in the code. Thank you!

    Private Sub CommandButton1_Click()

    Dim OutApp As Outlook.Application
    Dim MyItem As Outlook.MailItem
    Dim blnOLOpen As Boolean

    'Open Outlook if not open already
    On Error Resume Next

    Set OutApp = GetObject(, "Outlook.Application")
    blnOLOpen = True

    If OutApp Is Nothing Then
    Set OutApp = CreateObject("Outlook.Application")
    blnOLOpen = False
    Shell ("OUTLOOK")
    End If

    On Error GoTo 0

    Set MyItem = OutApp.CreateItem(olMailItem)


    With MyItem
    .To = "eagleinsight@eagleinsight.com"
    .Subject = ListBox7.Value & / & TextBox2.Value & / & TextBox4.Value & / & ListBox1.Value & _
    .Body = "A: " & ListBox7.Value & ListBox8.Value & vbNewLine & _
    "B*: " & TextBox2.Value & vbNewLine & _
    "C: " & TextBox3.Value & vbNewLine & _
    "D: " & ListBox1.Value & vbNewLine & _
    "E: " & ListBox2.Value & vbNewLine & _
    "F: " & TextBox5.Value & vbNewLine & _
    "G: " & TextBox4.Value & vbNewLine & _
    "H: " & ListBox5.Value & vbNewLine & _
    "I: " & ListBox6.Value & vbNewLine & _
    .display
    End With

    End Sub

  2. #2
    Forum Expert Tinbendr's Avatar
    Join Date
    06-26-2012
    Location
    USA
    MS-Off Ver
    Office 2010
    Posts
    2,138

    Re: Userform prepopulate email

    I would say that
     & / &
    should be
     & "/" &
    David
    (*) Reputation points appreciated.

  3. #3
    Valued Forum Contributor
    Join Date
    11-15-2008
    Location
    ph
    MS-Off Ver
    2007/2010/2016
    Posts
    479

    Re: Userform prepopulate email

    Hi -

    Aside from the typo that Tinbendr pointed out, you need to add reference to Outlook to get rid of user define error.

    Tools > References > Microsoft Outlook xx.x Object Library

    Go back to your post and put a code tags
    ...your code here...
    event

  4. #4
    Registered User
    Join Date
    01-09-2014
    Location
    New York
    MS-Off Ver
    Excel 2003
    Posts
    15

    Re: Userform prepopulate email

    Thanks both!
    I have made the changes but now am getting an "expected function or variable" error message with respect to the .display (after the body). I even changed the line .display to myitem.display and .send. both didnt work

    Any advice?

  5. #5
    Forum Expert Tinbendr's Avatar
    Join Date
    06-26-2012
    Location
    USA
    MS-Off Ver
    Office 2010
    Posts
    2,138

    Re: Userform prepopulate email

    Remove the trailing & _ just before the .Display.

  6. #6
    Registered User
    Join Date
    01-09-2014
    Location
    New York
    MS-Off Ver
    Excel 2003
    Posts
    15

    Re: Userform prepopulate email

    Quote Originally Posted by Tinbendr View Post
    Remove the trailing & _ just before the .Display.

    Thanks, worked in opening the email, but then only the email is filled with the subject as "false"

    Really appreciate it

  7. #7
    Forum Expert Tinbendr's Avatar
    Join Date
    06-26-2012
    Location
    USA
    MS-Off Ver
    Office 2010
    Posts
    2,138

    Re: Userform prepopulate email

    Same error on that line as well.

    Remove the trailing & _

    The underscore is a 'continuation' marker for VBA. Instead of one long line, it allows the line to be wrapped to underneath.

  8. #8
    Registered User
    Join Date
    01-09-2014
    Location
    New York
    MS-Off Ver
    Excel 2003
    Posts
    15

    Re: Userform prepopulate email

    you're a god Tinbendr

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 1
    Last Post: 01-22-2012, 02:47 PM
  2. How can i email the contents of a userform?
    By Richard in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-01-2006, 10:40 PM
  3. Email Userform
    By gachett in forum Excel General
    Replies: 0
    Last Post: 12-28-2005, 12:53 PM
  4. [SOLVED] how do set up a database to prepopulate details to a form in exce.
    By Squiggy56 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-14-2005, 12:06 PM
  5. [SOLVED] Email a Userform
    By Stuart in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-23-2005, 12:06 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1