Hi all, I'm running a basic macro to copy/paste/format emails to simplify reports that I'm handing off to my team.
(This will be the 3rd question I've posted here this weekend and I'm immensely grateful for all of the support and patience you've all shown)
As with most of my other questions, I've got a macro that *functionally* works, but it's missing the part that makes it look like I know what I'm doing..
The macro runs through 4 separate ranges in a worksheet. For each range it copies the selected area, pastes it into the email and centers the pasted table.
The issue I'm having is that even with
to create a new line, My tables seem to be nesting inside of each other.
Dims for context:
The Problem Code:
etc. etc.
So obviously I'm just copy/pasting my way through this and it felt great when the first two went in and looked right (similar widths), but the rest.. well, not so much..
Mainly, I'm just looking for a way to insert some type of break between the tables so they aren't connected.
Thoughts?
(This will be the 3rd question I've posted here this weekend and I'm immensely grateful for all of the support and patience you've all shown)
As with most of my other questions, I've got a macro that *functionally* works, but it's missing the part that makes it look like I know what I'm doing..
The macro runs through 4 separate ranges in a worksheet. For each range it copies the selected area, pastes it into the email and centers the pasted table.
The issue I'm having is that even with
VBA Code:
.Range.InsertParagraphBefore
Dims for context:
VBA Code:
Sub Macro7()
' Works in Excel 2000, Excel 2002, Excel 2003, Excel 2007, Excel 2010, Outlook 2000, Outlook 2002, Outlook 2003, Outlook 2007, and Outlook 2010.
Dim rng As Range
Dim OutApp As Object
Dim outMail As Object
Dim Location As String
Dim Signature As String
With Application
.EnableEvents = False
.ScreenUpdating = False
End With
'Open new mail item
Dim outlookApp As Object
Set outlookApp = CreateObject("Outlook.Application")
Set outMail = outlookApp.CreateItem(0)
'Get Word editor
outMail.Display
Dim wordDoc As Object
Set wordDoc = outMail.GetInspector.WordEditor
The Problem Code:
VBA Code:
'Copy contents
Sheets("Tables").Select
Range("AB7:AI75").Select
Range("AB7").Activate
Selection.Copy
'Paste as image (Centered)
wordDoc.Range.InsertParagraphBefore 'Create new empty paragraph before signature
wordDoc.Paragraphs.first.Range.PasteAndFormat Type:=wdChartPicture
wordDoc.Range.InsertParagraphBefore
With wordDoc.Tables(1).Rows
.WrapAroundText = 0 'If this is true does not work
.Alignment = 1
End With
'======== SECOND TABLE ========
'Copy contents (2)
Sheets("Tables").Select
Range("P7:Z29").Select
Range("P7").Activate
Selection.Copy
'Paste as image (Centered)(2)
wordDoc.Range.InsertParagraphBefore
wordDoc.Range.InsertParagraphBefore 'Create new empty paragraph before signature
wordDoc.Paragraphs.first.Range.PasteAndFormat Type:=wdChartPicture
With wordDoc.Tables(1).Rows
.WrapAroundText = 0 'If this is true does not work
.Alignment = 1
End With
'======== THIRD TABLE ==========
'Copy contents (3)
Sheets("Tables").Select
Range("F7:M30").Select
Range("F7").Activate
Selection.Copy
'Paste as image (Centered)(3)
wordDoc.Range.InsertParagraphBefore 'Create new empty paragraph before signature
wordDoc.Paragraphs.first.Range.PasteAndFormat Type:=wdChartPicture
With wordDoc.Tables(1).Rows
.WrapAroundText = 0 'If this is true does not work
.Alignment = 1
End With
etc. etc.
So obviously I'm just copy/pasting my way through this and it felt great when the first two went in and looked right (similar widths), but the rest.. well, not so much..
Mainly, I'm just looking for a way to insert some type of break between the tables so they aren't connected.
Thoughts?