2014-01-06 6 views
1

아래 매크로를 사용하여 시트에서 보이는 셀을 Outlook 전자 메일 본문에 붙여 넣으려고합니다. 매크로는 훌륭하게 작동합니다. 사람들이 전자 메일에 회신 할 때 갑자기 모든 행이 표시됩니다. 초기 이메일을 보내면 전체 시트를 붙여 넣어야하지만 필터링 된 행을 숨기려면 서식을 유지해야하지만 사람들이 답장을 보내면 모두 사라집니다. 어떤 아이디어?보이는 셀만 전자 메일 본문에 붙여 넣기하는 매크로

Sub Send_Range_Or_Whole_Worksheet_with_MailEnvelope() 
    'Working in Excel 2002-2013 
    Dim AWorksheet As Worksheet 
    Dim Sendrng As Range 
    Dim rng As Range 

    On Error GoTo StopMacro 

    With Application 
     .ScreenUpdating = False 
     .EnableEvents = False 
     .Application.DisplayAlerts = False 
    End With 

    'Fill in the Worksheet/range you want to mail 
    'Note: if you use one cell it will send the whole worksheet 
    Set Sendrng = Worksheets("APP").Range("A1").SpecialCells(xlCellTypeVisible) 

    'Remember the activesheet 
    Set AWorksheet = ActiveSheet 

    With Sendrng 
     ' Select the worksheet with the range you want to send 
     .Parent.Select 

     'Remember the ActiveCell on that worksheet 
     Set rng = ActiveCell 

     'Select the range you want to mail 
     .Select 

     ' Create the mail and send it 
     ActiveWorkbook.EnvelopeVisible = True 

     With .Parent.MailEnvelope 
      ' Set the optional introduction field thats adds 
      ' some header text to the email body. 
      .Introduction = "Below are the accounts currently falling outside of our High Cash tolerance. Please let us know if any action is needed. Thanks." 

      With .Item 
       .To = "[email protected]" 
       .CC = "" 
       .BCC = "" 
       .Subject = "APP High Cash" 
       .Send 
      End With 

     End With 

     'select the original ActiveCell 
     rng.Select 
    End With 
End Sub 
+0

예. 보이는 셀을 새 시트에 복사하고 해당 시트를 사용하여 전자 메일을 만듭니다. 완료되면 저장하지 않고 언제든지 통합 문서를 닫을 수 있습니다. –

답변

0

나는 이것을 테스트하지는 않았지만이 시트를 사용하여 시트의 숨겨진 행을 제거했습니다. 이 코드는 모든 행이 숨겨져 있으면 작동하지 않습니다.

Sub RemoveHiddenRows() 
Dim count4, count6 As Double   

    While Range("A" & CStr(count4 + 1)) <> "" 
     count4 = count4 + 1 
    Wend 

    count6 = 1 
    While count6 < count4 
     DoEvents 
     Application.StatusBar = "Deleting hidden rows. " & count6 & " or " & " of "_ 
     & count4 & " done." 
     If Range("A" & CStr(count6)).EntireRow.Hidden = True Then 
      Range("A" & CStr(count6)).EntireRow.Delete 
     Else 
      count6 = count6 + 1 
     End If 
    Wend 
End With 

End Sub 
관련 문제