Advertisement
Guest User

Untitled

a guest
Apr 16th, 2012
575
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.44 KB | None | 0 0
  1. Using VB.NET to copy Excel Range (a table) to body of Outlook email
  2. Sub CopyFromExcelIntoEMail()
  3. Dim Doc As Word.Document
  4. Dim wdRn As Word.Range
  5. Dim Xl As Excel.Application
  6. Dim Ws As Excel.Worksheet
  7. Dim xlRn As Excel.Range
  8.  
  9. Set Doc = Application.ActiveInspector.WordEditor
  10. Set wdRn = Doc.Range
  11.  
  12. Set Xl = GetObject(, "Excel.Application")
  13. Set Ws = Xl.Workbooks("Mappe1.xls").Worksheets(1)
  14.  
  15. Set xlRn = Ws.Range("b2", "c6")
  16. xlRn.Copy
  17.  
  18. wdRn.Paste
  19. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement