引用:
アクティブなシートで、セルの選択範囲に罫線を付けて、
その範囲をメールの本文に罫線付きで貼り付ける
(標準モジュール)
---------------------------------------------------------
Sub CreateMailAndPasteRange()
If TypeName(Selection) <> "Range" Then
MsgBox "セル範囲が選択されていません。", _
vbExclamation, _
"参照エラー"
Exit Sub
End If
Dim rngTarget As Excel.Range
Set rngTarget = Selection
With rngTarget.Borders
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
Dim olkApp As Object 'Outlook.Application
Dim olkMailItem As Object 'Outlook.MailItem
On Error Resume Next
Set olkApp = GetObject(, "Outlook.Application")
If Err.Number <> 0 Then
Err.Clear
On Error GoTo 0
Set olkApp = CreateObject("Outlook.Application")
End If
On Error GoTo 0
Set olkMailItem = olkApp.CreateItem(0) 'olMailItem
Dim wrdDoc As Object 'Word.Document
With olkMailItem
.To = ""
.Subject = "件名"
.BodyFormat = 1 'olFormatPlain
.Body = ""
.BodyFormat = 2 'olFormatHTML
.Display
Set wrdDoc = .GetInspector.WordEditor
End With
rngTarget.Copy
wrdDoc.Paragraphs(1).Range.PasteExcelTable LinkedToExcel:=False, _
WordFormatting:=False, _
RTF:=False
Application.CutCopyMode = False
Set wrdDoc = Nothing
Set olkMailItem = Nothing
Set olkApp = Nothing
Set rngTarget = Nothing
End Sub
---------------------------------------------------------
以上のようなコードを実行できればよい、ということでしょうか。