2016-07-26 8 views
0

私は使っていたRon de Bruinからマクロを取得しましたが、参照列に "TRUE"を見つけることができません。 「TRUEは、」私はここに示されている彼のページから、元のコードを使用しました「はい」書く場合、それは動作しますが、チェックボックスから生成されます。は、メールから範囲マクロへの "true"の検索に失敗します

Sub Test1() 
'For Tips see: http://www.rondebruin.nl/win/winmail/Outlook/tips.htm 
'Working in Office 2000-2016 
Dim OutApp As Object 
Dim OutMail As Object 
Dim cell As Range 

Application.ScreenUpdating = False 
Set OutApp = CreateObject("Outlook.Application") 

On Error GoTo cleanup 
For Each cell In Columns("B").Cells.SpecialCells(xlCellTypeConstants) 
    If cell.Value Like "?*@?*.?*" And _ 'right value is being shown 
     LCase(Cells(cell.Row, "D").Value) = "TRUE" Then 'suddenly skips this phase. 
              'Shows the right row but nothing happens anymore 

     Set OutMail = OutApp.CreateItem(0) 
     On Error Resume Next 
     With OutMail 
      .To = cell.Value 
      .Subject = "Reminder" 
      .Body = "Dear " & Cells(cell.Row, "A").Value _ 
        & vbNewLine & vbNewLine & _ 
        "Please contact us to discuss bringing " & _ 
        "your account up to date" 
      'You can add files also like this 
      '.Attachments.Add ("C:\test.txt") 
      .Display 'Or use Display 
     End With 
     On Error GoTo 0 
     Set OutMail = Nothing 
    End If 
Next cell 

cleanup: 
Set OutApp = Nothing 
Application.ScreenUpdating = True 
End Sub 

私はそれが魔法のように動作And _ LCase(Cells(cell.Row, "D").Value) = "TRUE"を削除した場合。私は誰かがこれで私を助けることを願っています。

+0

編集したコードと 'UCase()'のエラーはありますか?そうであれば、セルに 'True'(または' False'?)を書き込むコードを表示してください。 – user3598756

+0

@ user3598756 org投稿で述べたように、 "TRUE"がチェックボックスから生成されます – krib

+0

私はそれを読んだので、セルに書き込む特定のコード – user3598756

答えて

1

にそれを変更する必要がありますが正しくありません値はBooleanタイプ

の(ActiveX)チェックボックスにリンクされていますので、

If Cells(cell.Row, "D").Value Then 'means IF Cells(cell.Row, "D").Value = True 
+0

Thx。朝にそのショットを与えるつもりです。正しいことに聞こえる – krib

+0

これは魅力的なように働いた – krib

+0

喜んで助けになる – user3598756

1

次の行は、あなたがLCase機能(例えばtrue)を使用して、値を小文字に変換している

LCase(Cells(cell.Row, "D").Value) = "TRUE" Then 

...あなたはそのセル以降

UCase(Cells(cell.Row, "D").Value) = "TRUE" Then 
+0

私はそれを試みましたが、多くの違いはありません – krib

関連する問題