+ Reply to Thread
Results 1 to 4 of 4

Store range into array?

  1. #1
    Registered User
    Join Date
    03-18-2013
    Location
    Chicago
    MS-Off Ver
    Excel 2010
    Posts
    17

    Store range into array?

    I cant figure out how to set .HTMLBody as the contents of sheet1 (which contains unformatted HTML). Here is the code I'm using (it's also included in the attached workbook):

    Sub Mail_Sheet_Outlook_Body()

    Dim OutApp As Object
    Dim OutMail As Object

    With Application
    .EnableEvents = False
    .ScreenUpdating = False
    End With

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

    On Error Resume Next
    With OutMail
    .To = "[email protected]"
    .CC = ""
    .BCC = ""
    .Subject = "hi"
    .HTMLBody = "?????????????????????????????????????????????"
    .Display
    End With
    On Error GoTo 0

    With Application
    .EnableEvents = True
    .ScreenUpdating = True
    End With

    Set OutMail = Nothing
    Set OutApp = Nothing
    End Sub
    Attached Files Attached Files
    Last edited by matchooo; 07-03-2013 at 06:03 PM.

  2. #2
    Forum Contributor
    Join Date
    11-25-2010
    Location
    Glasgow, Scotland
    MS-Off Ver
    Excel 2007
    Posts
    120

    Re: Store range into array?

    Hi Matchooo,

    Your HTMLBody has to be one continuous string so if you want to send the info on sheet1 trying concatenating it all into one cell. In this file I added a column before the HTML with this function in A1:

    Please Login or Register  to view this content.
    Then all you have to do is change:

    Please Login or Register  to view this content.
    Alternatively you can do the concatenation in the code to build the HTML string check this page for more info especially the RangeToHTML Macro - http://msdn.microsoft.com/en-us/libr...ffice.11).aspx

    Depends if the length will change.
    If the post was helpful please click the black star on the bottom left to add some reputation and mark your thread as SOLVED.

    A day with nothing new achieved or learned, albeit however small, is a day lost forever?

    Constant Never Ending Improvement

  3. #3
    Registered User
    Join Date
    03-18-2013
    Location
    Chicago
    MS-Off Ver
    Excel 2010
    Posts
    17

    Re: Store range into array?

    Thanks! This works, but is there any way to automate the concatenation of the cells through VBA?

  4. #4
    Forum Contributor
    Join Date
    11-25-2010
    Location
    Glasgow, Scotland
    MS-Off Ver
    Excel 2007
    Posts
    120

    Re: Store range into array?

    Here this includes a section which will create the HTML from the range in the code:

    Please Login or Register  to view this content.
    Don't forget to add reputation by clicking the star on the bottom left if you're query is solved. Mark the thread as Solved too.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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