Sub MyWdMailAtt()
  Rem *----*----*    *----*----*    *----*----*    *----*----*
  Rem Word文書添付ファイル電子メール送信処理
  Rem 作譜:Hitrock Camellia Shinopy
  Rem 言語:Word VBA
  Rem 機能...
  Rem   開いているWordの文書を電子メールの添付ファイルとして送信する。
  Rem 注記...
  Rem   1. Microsoft Outlook上で、下記の手作業による事前設定が必要。
  Rem      Microsoft Outlookのメニューバーの[ツール]から[オプション...]をクリックし、
  Rem      [メール形式]タブの[電子メールの編集にMicrosoft Wordを使用する]チェックボックスを
  Rem      オンにする。
  Rem   2. Microsoft Outlookが起動済みの状態である場合、すぐに電子メールが送信される。
  Rem      起動してない場合は、これを起動して[送受信]ボタンを押して送信する必要がある。
  Rem   3. 警告なしに送信する。
  Rem 履歴...
  Rem   第1版:2006/07/03:作成。
  Rem *----*----*    *----*----*    *----*----*    *----*----*
  Rem 参照設定する場合...
  Rem   Microsoft Outlook 10.0 Object Library
  Rem *----*----*    *----*----*    *----*----*    *----*----*
  Dim myOutlook As Variant ' Outlook.Application
  Dim myMail As Variant ' MailItem
  Dim myCmmdBar As CommandBar
  Dim myCtrl As CommandBarControl
  Rem *----*----*    *----*----*    *----*----*    *----*----*
  '
  Select Case True
    Case Len(ActiveDocument.Path) = 0
      MsgBox "新規作成の文書です。" & vbCrLf _
        & "一旦、名前を付けて保存して下さい。", vbCritical + vbOKOnly, "MyWdMailAtt"
      Exit Sub
    Case ActiveDocument.Saved = False
      MsgBox "文書が更新されています。" & vbCrLf _
        & "一旦、上書き保存して下さい。", vbCritical + vbOKOnly, "MyWdMailAtt"
      Exit Sub
  End Select
  Rem *----*----*    *----*----*    *----*----*    *----*----*
  '
  On Error Resume Next
  Set myOutlook = GetObject(, "Outlook.Application")
  If Err.Number <> 0 Then
    Set myOutlook = CreateObject("Outlook.Application")
  End If
  On Error GoTo 0
  '
  Set myMail = myOutlook.CreateItem(0) ' = myOutlook.CreateItem(olMailItem)
  With myMail
    .Subject = "このメールはテストです。"
    .To = "xxxxxxxxx@xxx.com"
    .BCC = "xxxxxx@xxxx.ne.jp"
    .FlagRequest = "凄い!"
    .Importance = 2 ' = olImportanceHigh
    Rem   olImportanceHigh olImportanceLow olImportanceNormal
    Rem メッセージ形式...
    Rem   テキスト形式の場合、書式設定(文字色・蛍光ペン書式など)は無効になる。
    .BodyFormat = 1 ' = olFormatPlain / 2 = olFormatHTML
    .Attachments.Add ActiveDocument.FullName
    .Body = "添付ファイルを送付します。" & vbCrLf
    .Display
  End With
  Rem *----*----*    *----*----*    *----*----*    *----*----*
  '
  On Error Resume Next
  Application.CommandBars("Zzz").Delete
  On Error GoTo 0
  '
  Set myCmmdBar = Application.CommandBars.Add(Name:="Zzz", Position:=msoBarPopup, Temporary:=True)
  With myCmmdBar.Controls
    Set myCtrl = .Add(Type:=msoControlButton, ID:=3708)
    With myCtrl
      .Caption = "送信"
      .DescriptionText = "電子メールの送信コマンドを実行します。"
      .Execute
    End With
  End With
  myCmmdBar.Delete
  Rem *----*----*    *----*----*    *----*----*    *----*----*
  '
  Set myOutlook = Nothing
  Set myMail = Nothing
  Set myCmmdBar = Nothing
  Set myCtrl = Nothing
End Sub ' MyWdMailAtt *----*----*    *----*----*    *----*----*    *----*----*
inserted by FC2 system