ªð¦^¦Cªí ¤W¤@¥DÃD µo©«

excel¶l¥ó±Hµo¦h°ÝÃD

ÁÂÁÂstillfish¡B¬O¥Î¤Ï¤F¡A¥i¬O²{¦b¦³¥t¤@­Ó°ÝÃD¡F¸ê®Æ¦³¨â­Ó¤H¦P®É­n±µ¦¬®É¡Aµ{¦¡§PŪ¥u·|±N³Ì«á¤@¦ì¦C¦b¦¬¥óªÌ¤W­±¡A½Ð°Ý³o¬O­þ­Ó³¡¥÷¦³»~?
¥t¥~½Ð°Ý§¨±aÀɮצì¸mªº³¡¥÷¤@ª½´ú¸Õ¤£¥X¨Ó¬O»yªk¿ù»~¶Ü?ÁÂÁÂ
  1. Sub SEND()
  2.     Dim OutApp As Object
  3.     Dim OutMail As Object
  4.     Dim FileName As String
  5.     Dim EmailTo As String
  6.     Dim EmailCC As String
  7.     Dim EmailBCC As String
  8.     Dim EmailSubject As String
  9.     Dim EmailBody As String
  10.     Dim cell As Integer
  11.    
  12.     SendType = CStr(Sheets("Sheet2").Cells(2, 2))
  13.      If SendType = "1" Then
  14.         cell = 8
  15.      ElseIf SendType = "2" Then
  16.         cell = 9
  17.      ElseIf SendType = "3" Then
  18.         cell = 10
  19.      ElseIf SendType = "4" Then
  20.         cell = 11
  21.      Else
  22.         cell = 0
  23.      End If

  24.      If cell > 0 Then
  25.         For i = 4 To 6 Step 1
  26.             If CBool(Sheets("Sheet2").Cells(i, cell)) = "TRUE" Then
  27.                 EmailTo = CStr(Sheets("Sheet2").Range("G" & i)) & ";"
  28.             End If
  29.         Next
  30.             EmailCC = CStr(Sheets("Sheet2").Range("G" & 7))
  31.             EmailBCC = CStr(Sheets("Sheet2").Range("G" & 8))
  32.             EmailSubject = CStr(Sheet2.Cells(2, 3))
  33.             EmailBody = CStr(Sheet1.Range("A" & 11)) & vbNewLine
  34.             
  35.             'If [Sheet1].Cells(8, 1) <> "" Then .AddAttachment ([Sheet1].Cells(8, 1))

  36.             If EmailCC <> "" Then
  37.                 Set rng = Sheets("Sheet1").Range("A11:G30").SpecialCells(xlCellTypeVisible)
  38.                 On Error Resume Next
  39.                 ' Only send the visible cells in the selection.
  40.                 'Set rng = Selection.SpecialCells(xlCellTypeVisible)
  41.                 On Error GoTo 0
  42.                 If rng Is Nothing Then

  43.                     MsgBox "The selection is not a range or the sheet is protected. " & _
  44.                            vbNewLine & "Please correct and try again.", vbOKOnly
  45.                     Exit Sub
  46.                 End If
  47.                 With Application
  48.                     .EnableEvents = False
  49.                     .ScreenUpdating = False
  50.                 End With

  51.                 Set OutApp = CreateObject("Outlook.Application")
  52.                 Set OutMail = OutApp.CreateItem(0)
  53.            
  54.                 On Error Resume Next
  55.                 On Error GoTo 0

  56.                 With OutMail
  57.                      .To = EmailTo
  58.                      .CC = EmailCC
  59.                      .BCC = EmailBCC
  60.                      .Subject = EmailSubject
  61.                      .body = EmailBody
  62. '                     .attachments.Add
  63.                      .display
  64.                  End With
  65.                 With Application
  66.                     .EnableEvents = True
  67.                     .ScreenUpdating = True
  68.                 End With
  69.                 Set OutMail = Nothing
  70.                 Set OutApp = Nothing
  71.             End If
  72.      End If
  73. End Sub
½Æ»s¥N½X

TOP

¦^´_ 11# Mindyj
line#28
     EmailTo = EmailTo & CStr(Sheets("Sheet2").Range("G" & i)) & ";"

line#67
    .attachments.Add "C:\aa.txt"
    ¬õ¦â¬°ªþÀɪº¸ô®|

¬O³o¼Ë¶Ü?

TOP

¦^´_ 12# stillfish00


Hi stillfish,
§¨±aÀɮ׫ü©w¬°shee1ªºa8Àx¦s®æ¡A§Ú¨Ï¥Î¤F
                 .AddAttachment Sheet1.Cells(8, 1)
debug·|°±¯d¦b.addattachment

TOP

¦^´_ 13# Mindyj


    ¸Õ¸Õ?
.attachments.add Sheet1.Cells(8, 1)

¤£¦æªº¸Ü·|¤£·|¬OA8¤Wªºªþ¥ó¦ì¸m¦³¿ù?
À´±oµo°Ý,µª®×´N·|¦b¨ä¤¤

¤µ¤éの¤@¬íは  ©ú¤éにない
http://kimbalko-chi.blogspot.com
http://kimbalko.blogspot.com

TOP

¦^´_ 14# kimbal

ÁÙ¬O¤£¬O¡B«Ü¯Ç´e¡A¦]¬°³o¤@¦æ¤£°õ¦æªº¸Ü¾ã­Óµ{¦¡¬O¨S°ÝÃDªº¡AÀ³¸Ó¬O¤£»Ý­n¥t¥~¼gfunction?

TOP

¥»©«³Ì«á¥Ñ Mindyj ©ó 2013-5-31 14:15 ½s¿è

­è­è´ú¸Õ¤F¦pªG±N§¨±aÀɮת½±µ¿é¤JÀɮצì¸m¬O¥i¦æªº¡A

¥i¬O¨Ï¥ÎªÌ·|¨Ì¨C¦¸»Ý¨D¤£¦P¿ï¾Ü¤£¦PªºÀɮסB©Ò¥H¤~±NÀɮצì¸m«ü©w¿é¤J¦ÜSheet1ªºA8Àx¦s®æ¡A

¦ý¬O·í§Ú±N§¨±aÀɮקאּ«ü©w¦ÜÀx¦s®æ´N¤@ª½¥X²{¿ù»~¡A

¦Ó¿ù»~¤@ª½°±¯d¦b.attachments.add Sheet1.Cells(8, 1)

TOP

¦^´_ 16# Mindyj
.attachments.add Sheet1.Cells(8, 1).value

TOP

¥»©«³Ì«á¥Ñ Mindyj ©ó 2013-5-31 15:06 ½s¿è

¦^´_ 17# stillfish00
°õ¦æµ²ªG¡Gobject doesn't support this property or method

¤@­ÓÀYn­Ó¤j¡B½Ð°ÝÁÙ¦³§Oªº¤è¦¡¶Ü?

TOP

¦^´_ 18# Mindyj
¯àªþ¤W°õ¦æ·|¥X¿ùªºÀɮ׬ݬݶÜ

TOP

¦^´_ 17# stillfish00


    §ó¥¿!!!!¦¨¥\¤F!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    ÁÂÁÂstillfish!!!!!!:handshake

TOP

        ÀR«ä¦Û¦b : ¬°¤H³B¥@­n¤p¤ß²Ó¤ß¡A¦ý¤£­n¡u¤p¤ß²´¡v¡C
ªð¦^¦Cªí ¤W¤@¥DÃD