忍者ブログ
  • 2025.05《
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 》 2025.07
[PR]
×

[PR]上記の広告は3ヶ月以上新規記事投稿のないブログに表示されています。新しい記事を書く事で広告が消えます。

2025/06/19 15:54 |
Mail
Mail -11
0ption Explicit

Set oApp = CreateObject(″Outlook.Application″) .
Set obj∥AIL = oApp.Createitem(0)
'/Bodyフォーマット(1:テキスト形式、2:HTML形式、3:リッチテキスト形式)
objMAIL.BodyFormat = 2
objMAIL.display'編集画面を表示

'/ヘッダー
'#宛先など
obj∥AIL.SentOnBehalfOfName
objMAIL.To = Range(″,ヒうに″)
obj∥AIL.CC = Range(″CC″)
objMAIL.BCC = Range(″BCC″)

'#件名
objMAIL.Subject=Range(″件名″)
'#添付ファイル
添付ファイル

'/本文

'#改行コード取得
For i = l To 6
1f Range(″ヨ彙イテ″ & i) = True Then
strCL(i) = vbLf
Debug.Print strCL(i)
End lf
Next i
'捌ordEditor起動
With oApp.Activelnspector.WordEditor.Windows(1)
'#本文1
strMOJI = Range(″冽卜〕に1″)
Wlth .Selection
' .Font.Oolor = vbBlack 'vbRed
' .Font.Size = 20
.typetext strMOJl
End With

'#改行1
.Selection.typetext strCL(1)
'#図表1
i〓1
図表

'#本文2
str∥OJI = Range(″ヨトうに2″)
.Selection.typetext strMOJI
'#改行2
.Selection.typetext strCL(2)

'#図表2
i=2
図表

'#本文3
strMOJI = Range(″冽卜〕に3″)
.Selection.typetext str∥OJI
'#改行3
.Se!ection.typetext strCL(3)

'#図表3
i=3
図表

'#本文4
strMOJI = Range(″J卜5に4″)

=Range(″差出人″) '代理送信の場合、メール画面には表示されないが裏で設定される

.Selection.typetext strMOJI
'#改行4
.Selection.typetext strCL(4)

'#図表4
i=4
図表

'#本文5
str∥OJI = Range(″冽トラt5″)
.Selection.typetext strMOJl

'#改行5
.Selection.typetext strCL(5)

'#図表5
i=5
図表

'#本文6
str∥0」l 〓 Range(″フトラt6″)
.Selection.typetext str∥0」|

'#改行6
.Selection.typetext strCL(6)

'#図表6
i=6
図表

'#署名
.Selection.typetext vbCrLf & vbCrLf '改行X2
str∥OJI〓Range(″署名″)
.Selection.typetext str∥OJI
.Selection.typetext vbCrLf '改行

'#改行7
Selection.typetext strCL(7)

'#本文7
strMOJI = Range(″フトラt7″)
.Selёction.typetext str∥OJl

End With


変数の解放

End Sub

On Error GoToファィルが見つからない

For i = l To 5
1f Not isEmpty(Range(″添付ファイル″&i))Then
strTMP(1)=Range(″添付ファイル″&i)
objMAIL.Attachments.Add strTMP(i)
End lf
Next i

Ex:t Sub

フアイルが見つからない:
AppActivate″Microsoft Excel″,False 'Excelをアクティブにする
MsgBox″添付ファイルが見つかりません。 ″&vbCrLf&″添付ファイル″&i,vbCritica
変数の解放
End

End Sub



On Error GoToファイルが見つからない

With oApp.Activelnspector.WordEditor.Windows(1)

lf Range(″図表″&i)=True Then

spBK=Range(″図表ファイル名″&i)
SpSH=Range(″図表シート名″&i)
SpRG=Range(″図表範囲″&i)
Select Case Range(″図表形式″&i)
Case ″
Range(″図表形式″&i)=″表″
表の貼付
case rョ長″
表の貼付
Case″表(リッチテキスト形式)″
リッチテキスト形式で表の貼付
Case″図(拡張メタファイル)″
拡張メタファイルで表の貼付
End Select
.Selection.typetext vbCrLf '改行
End lf

End With

Exlt Sub

フアイルが見つからない:
AppActivate″Microsoft Excel″,False 'Excelをアクティブにする
MsgBox″図表を挿入するファイルが開かれていません。 ″&vbCrLf&″図表挿入″&i,vbCritical
変数の解放
End

End Sub

With oApp.Activelnspector.WordEditor.Wlndows(1)
Workbooks(spBK).Worksheets(SpSH).Range(SpRG).Oopy
.Selection.Paste
Application CutCopyMode = False
End With
End Sub

With oApp.Activelnspector.WordEditor.Windows(1)
' Debug.Print Workbooks(spBK).Name
l:[|:::|:1,::さなbttl[[il::|:(P:::な:R::早:`,pl,をし0°py
Applicatlon.CutCopy∥ode = False
End With
End Sub

'非リンク,Excel書式, リッチテキスト形式

With oApp Activeinspector.WordEditor.Windows(1)
∥:[|:::|:1:::[セbW°rkSheets(SpSH) Range(SpRG).OopyPicture
Application,CutCopyMode = False
End With
End Sub
PR
2016/04/19 00:54 | VBA-Mail | コメント(0)
GetShape
GetShape - 1
9罪りЪ留りiβ兼タンの名前は、[ホーム]一[検索と選択]―[オブジェクトの選択と表示]で表示される
Application,ScreenUpdating = Fa:se
'/オブジェクトボタンの名前を取得
i = Right(Application.Caller, 1)
Set mySH = ActiveSheet
spBK=Range(″'[″&ThisWorkbook.Name&″]″&mySH.Name&″'!図表ファイル名″&i)
::RI : “|:' : I∥|:∥:|∥:::∥:∥:∥: : “:“ : ∥挙:∥:∥:∥: : “||[]:E:`:ョ」卜1「| & i
lf spBK = ″″ Then
MsgBox″図表を挿入するファイル名が入力されていません。 ″&vbCrLf&″図表挿入″&i,vbCritical
End
End lf
On Error GoToファイルが見つからない
Workbooks(spBK).Activate
Range(SpSH) = ActiveSheet.Name
Range(SpRC) = Selection.Address(RowAbsolute:〓Fa:se, OolumnAbsolute:=False)
Application.ScreenUpdating = True
mySH.Activate
変数の解放
Exit Sub
フアイルが見つからない:
MsgBox″図表を挿入するファイルが開かれていません。 ″&vbCrLf&spBK,vbCritica!
変数の解放

End
End Sub

Application.ScreenUpdating = Faise
'/オブジェクトボタンの名前を取得
i = Right(App::cation Caller, 1)
Set mySH 〓 ActiveSheet
Range(″図表範囲″&i).Activate
:::∥ 二 l:1::{“| :' : I∥|:∥:II:::I:∥:冊: : “]“
SpRG = Range(″'[″ & ThisWorkbook.Name & ″]″

Application.ScreenUpdating 〓 True .
On Error GoToファィルが見つからない
Workbooks(spBK).Worksheets(SpSH).Activate
ActiveWindow.WindowState = xlNormal
Range(SpRG).Select
変数の解放
Exit Sub
フアイルが見つからない:
Range(″図表ファイル名″&i).Activate
MsgBox″図表を挿入するファイルが見つかりません。 ″&vbCrLf&″(開いていません)″,vbCritical
変数の解放
End
End Sub

&mySH.Name&″'!図表ファイル名″&i)
&mySH.Name&″'!図表シート名″&i)
& mySH.Name & ″'!ロコ暑長庫垣Eヨ″ & i)

GetShape - 2
Application.ScreenUpdating = False
'/オブジェクトボタンの名前を取得
i=Right(Alplicatllono cal ler,1)
Set mySH = ActiveSheet
i:1::1“:]:言1;1,1ツ′F43'A[S「子.ёlearcontbnts
Range(r図表シート名″&`1).ClearContents
Range(″図表範囲″&i):ClearContents
Range(″図表形式″&i).ClearContents
Application.ScreenUpdating ¬ True
変数の解放
End Sub
2016/04/19 00:31 | VBA-Mail | コメント(0)
Cell Format
Cell Format - 1
0ption Explicit
)なら以下の書式を設定

Range(myRng.Offset(y, x), myRng)
.Borders(xlEdgeTop).Weight = xlMedium

Borders(xlEdgeTop).Color=16711680 '青線
Borders(xlEdgeBottom).Weight = xlMedium

.Borders(xlEdgeBottom).Oolor 〓 16711680
.Borders(xlEdgeLeft)。Weight = xl∥ed i uln
.Borders(x!EdgeLeft).Oolor = 16711680

.Borders(xlEdgeRight)Weight = xl∥edium
.Borders(xlEdgeRight).Oolor = 16711680

End W:th
lf x = -l Then
myRng.Offset(y, x). lnterior.Oolor = 15849925 'ItttE
Else
Range(myRng.Offset(y, x), myRng.Offset(0, -1)). lnterlor.Oolor = 15849925 '「辱tL
End lf

End Sub
なら以下の書式を設定
With Range(myRng.Offset(y, x), myRng)
.Borders(xlEdgeTop).Weight = xl∥edium
Borders(x:EdgeTop).Color = 16711680 '青線
.Borders(xlEdgeBottom).Weight = xlMedium
.Borders(xlEdgeBottom).Oolor = 16711680
.Borders(xlEdgeLeft).Weight = xlMedium
.Borders(xlEdgeLeft).Oolor = 16711680
.Borders(xlEdgeRight).Weight = xl∥edium
.Borders(xlEdgeRight).Oolor 〓 16711680
End With
lf x = -l Then
myRng.Offset(y, x). lnterior.Color = 15849925 '5RtL
Else
Range(myRng.Offset(y, x), myRng.Offset(y, -1)). lnterior.Oolor = 15849925 '層辱(菫
End lf

End Sub
)なら以下の書式を設定
With Range(myRng.Offset(y, x), myRng)
Borders(xlEdgeTop).Weight = xlThin
.Borders(x:EdgeTop).Oolor = 0 '月晨t三
Borders(xlEdgeBottom).Weight = xlThin
Borders(xlEdgeBottom).Color = 0
Borders(xlEdgeLeft).Weight = xlThin
Borders(xlEdgeLeft).Color = 0
Borders(xlEdgeRight).Weight = xlThin
.Borders(xlEdgeRight).Oolor = 0
End With
With Range(myRng.Offset(y, -2), myRng.Offset(0, -1))

With

. lnterior.Oolor 〓 14540253

'灰色

hd"♀鶴“ドは∥“ideV針u“D■mesty降=剤日neStJ ttme
End Sub
状態により書式設定
if pCkbox.Value = True Then
With Range(myRng.Offset(y, x), myRng)
.Borders(xlEdgeTop)。Weight = xl∥edium
.Borders(xlEdgeTop).Oolor = 16711680
End With
End if
End Sub
状態により書式設定
lf nCkbox.Value 〓 True Then

Cell Format - 2
With Range(myRng.Offset(y, x), myRng)
.Borders(xlEdgeBottom).Weight 〓 xlMedlum
.3orders(xlEdgeBottom) Oolor = 16711680
End With
End lf
End Sub

lf myCkbox.Value = True Then
可変セル書式
Else
定型セル書式
End lf

End Sub



lf myCkbox.Value = True Then
可変セル書式
Else
定型セル書式
With myRng.Offset(y, x)
.Borders(xlEdgeBottom).LineStyle 〓 xlLineStyleNone
.8orders(xlEdgeLeft).LineStyle = xlLineStyleNone
End With
End lf

End Sub



lf myCkbox.Value = True Then
可変セル書式
Else
定型セル書式
With myRng.Offset(y, x)
End il:||:|:|||:|:::::t,lllili:li首「呈X:キ:lili:li!|:i:ne
End lf

End Sub

lf myCkbox.Value ≡ True Then
可変セル書式
E:se
定型セル書式
With myRng.Offset(y, x)
.Borders(xlEdgeTop).LineStyle =
End "::iders(XIEdgeLeft).LineStyle =
End if

End Sub

xlLineStyleNone
xlLineStyleNone

lf myCkbox.Value = True Then
可変セル書式
Else
定型セル書式
[lihivlil::∫:そll:a::::::`∥).[lhe:I;I:・2fil[11:stテ|をキ。ne
End if

End Sub
2016/04/19 00:29 | VBA-Mail | コメント(0)
Common
Commonr_ 1
0ption Explicit
Public mySH As Worksheet
'シート上のチェックボックス用

Public myCkbox As Object
Public pCkbox As Object
:廿:||: 1:∥∥:XA:SR:∥::Ct
Public x As Long
Public y As Long

'メール送信用
Public oApp As Object
Public objMAIL As Object

Public str∥OJI As String
Public strSign As String
Public strTMP(7) As String
Public strCL(8) As String

Public i As Long

Sub変数の解放0

Set mySH = Nothing
Set myCkbox = Nothing
Set pCkbox 〓 Nothing
Set nCkbox = Nothing
Set myRng = Nothing

End Sub

'上のセルのチェックボックス
'下のセルのチェックボックス

'Offsetの列移動値-l or-2
'Offsetの行移動値O or 4


'Outiookのオブジェクト
'メールのオブジェクト

'本文
'署名
'添付ファイル
'改行コード



'図表(Shape)のファイル名
'図表(Shape)のシート名
'図表(Shape)のセル範囲

ggg
nnn


ttt
SSS


AAA

KHG
BSR
ppp
SSX0

CCC


bbb
uuu
PPP

g
n

hg
tn ″
0・‥ ″
Nh
t 6〓
一¨0
N o>
・L T‥―
―一一 <
A lL
=p C
・Jp 一一r
LDA +‥―
00 ,‥S
t
+Ft r x
ee O e
SS F N
2016/04/19 00:27 | VBA-Mail | コメント(0)
| ホーム |