getting Excel data into body 
Author Message
 getting Excel data into body

I am using Automation to run Outlook from Excel.  In the
past I have always sent the Excel file as an attachment.  
What I want to do now is get the Excel data into the body
of the mail item.  What I want the body to look like is:

Here's your information:

<Excel data line1>
<Excel data line2>
<etc. . .>

the End

What I currently have:
MyText = "Here's your information:" & Chr(13)
MyText = MyText & "the end"
.Body = MyText

I can't figure out how to get the Excel data between the
first MyText and the second MyText, but I think I'm going
down the wrong path.

Thanks,
Dion



Wed, 02 Nov 2005 04:15:23 GMT  
 getting Excel data into body
If objWS is your Worksheet object, objWS.Cells(j,k) returns the value in the cell in the jth row and the kth column, e.g. Cells(1,1) for the first cell. So, if your data is in the first three columns of rows 6-11, you could build a string like this:

strData = ""
For j = 1 to 2
    For k = 6  to 11
        strData = strData & " " & objWS.Cells(j, k)
    Next
    strData = Trim(strData) & vbCrLf
Next
MyText = "Here's your information:" & Chr(13)
MyText = MyText & strData & "the end"
.Body = MyText

--
Sue Mosher, Outlook MVP
Outlook and Exchange solutions at http://www.slipstick.com
Author of
     Microsoft Outlook Programming: Jumpstart
     for Administrators, Power Users, and Developers
     http://www.slipstick.com/books/jumpstart.htm

Quote:

> I am using Automation to run Outlook from Excel.  In the
> past I have always sent the Excel file as an attachment.  
> What I want to do now is get the Excel data into the body
> of the mail item.  What I want the body to look like is:

> Here's your information:

> <Excel data line1>
> <Excel data line2>
> <etc. . .>

> the End

> What I currently have:
> MyText = "Here's your information:" & Chr(13)
> MyText = MyText & "the end"
> .Body = MyText

> I can't figure out how to get the Excel data between the
> first MyText and the second MyText, but I think I'm going
> down the wrong path.

> Thanks,
> Dion



Wed, 02 Nov 2005 04:34:12 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Creating Excel Spreadsheet from Outlook message body data

2. Getting data from security-enabled Access 2 to Excel 7 using DAO

3. Getting Tab separated data from Word to Access, Excel or simply process it from VB

4. Getting real-time data from Excel

5. Getting data of an Outlook/Exchange folder to Excel

6. Need help getting data from an excel file

7. help needed getting Excel data into TSV Actual Work

8. Getting Tab separated data from Word to Access, Excel or process it from VB

9. Getting Cell data from excel into a variable

10. Getting Data out of Excel

11. Getting data from Excel to VB using ADO problem

12. Getting Data from Excel

 

 
Powered by phpBB® Forum Software