+ Reply to Thread
Results 1 to 15 of 15

Text Box to Email Body

  1. #1
    Forum Contributor
    Join Date
    08-07-2013
    Location
    mo
    MS-Off Ver
    Excel 2010
    Posts
    453

    Text Box to Email Body

    I am trying to copy the contents of a textbox to the body of my email The VBA below works except that part. The issue is I need to pull the content (it is a sentance) from textbox 3 in my excel sheet, but it is currently writting textbox 3 instead of pulling its content. Thanks for help.

    Please Login or Register  to view this content.

  2. #2
    Forum Expert
    Join Date
    01-23-2013
    Location
    USA
    MS-Off Ver
    Microsoft 365 aka Office 365
    Posts
    3,863

    Re: Text Box to Email Body

    Please Login or Register  to view this content.

  3. #3
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,887

    Re: Text Box to Email Body

    What happens if you remove the quotation marks from around TextBox3.Text in your line of code? Does that solve it?
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  4. #4
    Forum Contributor
    Join Date
    08-07-2013
    Location
    mo
    MS-Off Ver
    Excel 2010
    Posts
    453

    Re: Text Box to Email Body

    Without the quotation marks it comes back as:

    Run-time error '424':

    Object Required

  5. #5
    Forum Expert
    Join Date
    01-23-2013
    Location
    USA
    MS-Off Ver
    Microsoft 365 aka Office 365
    Posts
    3,863

    Re: Text Box to Email Body

    It can't find 'TextBox3'. If you're using UserForms, see below. If not using UserForms, you may
    need to reference a sheet name, or a Workook name and Sheet name.

    Please Login or Register  to view this content.
    If 'TextBox3' is a named cell try:
    Please Login or Register  to view this content.
    Last edited by LJMetzger; 09-24-2013 at 05:24 PM.

  6. #6
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Text Box to Email Body

    Hello mattress58,

    If this is an ActiveX control on the worksheet then code should be...
    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  7. #7
    Forum Contributor
    Join Date
    08-07-2013
    Location
    mo
    MS-Off Ver
    Excel 2010
    Posts
    453

    Re: Text Box to Email Body

    Changing to ".body = Worksheets("Sheet1").OLEObjects("TextBox3").Object.Value" gets me this error:
    Run-time error '1004':
    Unable to get the OBLEObjects property of the worksheet class

    Changing to ".body = Sheets("Sheet1").Range("TextBox3").Text" gets me the '424' error again:

    The macro part I am trying to run is attahced and how I am trying to make it look if that helps.

    Thank yall so much for helping me with this.
    Attached Images Attached Images
    Attached Files Attached Files

  8. #8
    Forum Contributor
    Join Date
    01-18-2013
    Location
    Prague, Czech rep.
    MS-Off Ver
    Excel 2003 - 2016
    Posts
    138

    Re: Text Box to Email Body

    Hi,

    I might be wrong but im not sure with your declarations, i kind of a miss mailitem in which body object should be if im not mistaken and therefore those otherwise correct codes are not runing. But prolly I´m out of my rocket, I´m able to reproduce a certain code to e-mail things, but I cant run deep in the code.

    Best regards

    Soul

    EDIT: Just to show what i mean, this is the part of a code (declarations) i use when e-mailing via VBA:

    Please Login or Register  to view this content.
    and then the actual filling for mail (to, cc, subject, body etc.); and i never had a prob with using variables to fill in these things
    Last edited by SoulPrisoner; 09-25-2013 at 08:32 AM. Reason: Additional info

  9. #9
    Forum Contributor
    Join Date
    08-07-2013
    Location
    mo
    MS-Off Ver
    Excel 2010
    Posts
    453

    Re: Text Box to Email Body

    I just tried switiching to:

    Dim OutApp As Outlook.Application
    Dim OutMail As Outlook.MailItem
    Set OutApp = CreateObject("Outlook.Application")
    Set OutMail = OutApp.CreateItem(olMailItem)
    With OutMail

    and it came back Compile error:
    User-defined type not defined

  10. #10
    Forum Contributor
    Join Date
    01-18-2013
    Location
    Prague, Czech rep.
    MS-Off Ver
    Excel 2003 - 2016
    Posts
    138

    Re: Text Box to Email Body

    Hm, you do have preferences set up correctly right (with outlook library activated to get outlook object) tools - preferences - ...?

  11. #11
    Forum Expert
    Join Date
    01-23-2013
    Location
    USA
    MS-Off Ver
    Microsoft 365 aka Office 365
    Posts
    3,863

    Re: Text Box to Email Body

    Hi mattress58 and fellow posters,

    After opening the workbook that mattress58 posted, I think I found a solution.
    There seemed to be two problems:
    1. mattress58 was referencing 'TextBox3', when the real name was 'TextBox 3' (with a SPACE).
    2. 'TextBox 3' is a 'Shape' in 'Sheet1' (the active sheet) of the workbook.

    I do not have access to 'Outlook', but I tested as much of the following solution as I could. From my research, it appears that the '.body' line needs text. I am not a 'Shapes' expert, but I was able to get the following code to work.

    Please Login or Register  to view this content.

    Implement function 'GetTextBox3Value()' as follows:
    Please Login or Register  to view this content.

  12. #12
    Forum Contributor
    Join Date
    08-07-2013
    Location
    mo
    MS-Off Ver
    Excel 2010
    Posts
    453

    Re: Text Box to Email Body

    Thank you helping. Am I replacing:
    Body = "TextBox3.Text"
    with
    .body = GetTextBox3Value

    This allows the macro to complete without errors but doesnt bring the data in the shape to the email.
    Do I need intergrate the code above into my code?

    Sorry if these are dumb questions, I am trying to make my work a ton easier and I am not experienced with this.

    Thanks for help

  13. #13
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Text Box to Email Body

    Hello mattress58,

    I think I know what the problem is. You are using an MSO text box and not an ActiveX. They can be distinguished by the naming convention but are so similar it is easy to confuse them. The ActiveX name contains no spaces "TextBox1". The MSO text box adds a space before the number "TextBox 1".

    Try this and see it doesn't work. Change the worksheet name if needed.
    Please Login or Register  to view this content.

  14. #14
    Forum Contributor
    Join Date
    08-07-2013
    Location
    mo
    MS-Off Ver
    Excel 2010
    Posts
    453

    Re: Text Box to Email Body

    Leith....... YOU ARE THE MANNNNN!!!!!!!!!...... Thanks everyone for the help, that worked.

  15. #15
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Text Box to Email Body

    Hello mattress58,


    You're welcome. Glad we got it solved.

+ 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. Body Text in Email
    By nickysquawkes in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-05-2013, 03:38 PM
  2. Encode Text Of Body Of Email Into HTML
    By WJO in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-14-2012, 02:27 PM
  3. Replies: 4
    Last Post: 02-27-2012, 03:13 AM
  4. Generate Email Body Text
    By Swift4Play in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-14-2011, 08:35 AM
  5. [SOLVED] Email Body Text & Signature
    By Darrell Lankford in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-07-2006, 12:55 PM

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