我在下面的编码中收到一个错误,标记行中的 Object Required。请帮帮我。Temp文件是一个模板,详细信息来源于Combo代码,Combo代码是需要填写在模板中的数据,根据下面的代码发送电子邮件。
Sub Emails()
Dim R_No As Integer
Templ.Select
Templ.Range("C11") = ""
Templ.Range("D11") = ""
Templ.Range("E11") = ""
Temp1.Range("F11") = "" <-------- Error
Temp1.Range("G11") = ""
Templ.Range("C14") = ""
Templ.Range("D14") = ""
Templ.Range("E14") = ""
Temp1.Range("F14") = ""
Temp1.Range("G14") = ""
Rows("10:11").Select
Selection.EntireRow.Hidden = True
Rows("13:14").Select
Selection.EntireRow.Hidden = True
R_No = 2
Do Until Combo.Cells(R_No, 1) = ""
If Combo.Cells(R_No, 1) = "Order" Then
Combo.Cells(R_No, 13) = Combo.Cells(R_No, 2)
Else
Combo.Cells(R_No, 13) = Combo.Cells(R_No, 2) & " & " & Combo.Cells(R_No, 4)
End If
If Combo.Cells(R_No, 7) = Combo.Cells(R_No + 1, 7) Then
If Combo.Cells(R_No, 1) = Combo.Cells(R_No + 1, 1) Then
If Combo.Cells(R_No, 1) = "Order" Then
Rows("10:11").Select
Selection.EntireRow.Hidden = False
If Templ.Range("C11") = "" Then
Templ.Range("C11") = Combo.Cells(R_No, 2)
Templ.Range("D11") = Combo.Cells(R_No, 3)
Templ.Range("E11") = Combo.Cells(R_No, 5)
Temp1.Range("F11") = Combo.Cells(R_No, 6)
Temp1.Range("G11") = Combo.Cells(R_No, 9)
Else
Templ.Range("C11") = Templ.Range("C11") & Templ.Range("I2") & Combo.Cells(R_No, 2)
Templ.Range("D11") = Templ.Range("D11") & Templ.Range("I2") & Combo.Cells(R_No, 3)
Templ.Range("E11") = Templ.Range("E11") & Templ.Range("I2") & Combo.Cells(R_No, 5)
Templ.Range("F11") = Templ.Range("F11") & Templ.Range("I2") & Combo.Cells(R_No, 6)
Templ.Range("G11") = Templ.Range("G11") & Templ.Range("I2") & Combo.Cells(R_No, 9)
End If
End If
If Combo.Cells(R_No, 1) = "Receipt" Then
Rows("13:14").Select
Selection.EntireRow.Hidden = False
If Templ.Range("C14") = "" Then
Templ.Range("C14") = Combo.Cells(R_No, 2) & "-" & Combo.Cells(R_No, 4)
Templ.Range("D14") = Combo.Cells(R_No, 3)
Templ.Range("E14") = Combo.Cells(R_No, 5)
Temp1.Range("F14") = Combo.Cells(R_No, 6)
Temp1.Range("G14") = Combo.Cells(R_No, 9)
Else
Templ.Range("C14") = Templ.Range("C14") & Templ.Range("I2") & Combo.Cells(R_No, 2) & "-" & Combo.Cells(R_No, 4)
Templ.Range("D14") = Templ.Range("D14") & Templ.Range("I2") & Combo.Cells(R_No, 3)
Templ.Range("E14") = Templ.Range("E14") & Templ.Range("I2") & Combo.Cells(R_No, 5)
Templ.Range("F14") = Templ.Range("F14") & Templ.Range("I2") & Combo.Cells(R_No, 6)
Templ.Range("G14") = Templ.Range("G14") & Templ.Range("I2") & Combo.Cells(R_No, 9)
End If
End If
Else
If Combo.Cells(R_No, 1) = "Order" Then
Rows("10:11").Select
Selection.EntireRow.Hidden = False
If Templ.Range("C11") = "" Then
Templ.Range("C11") = Combo.Cells(R_No, 2)
Templ.Range("D11") = Combo.Cells(R_No, 3)
Templ.Range("E11") = Combo.Cells(R_No, 5)
Temp1.Range("F11") = Combo.Cells(R_No, 6)
Temp1.Range("G11") = Combo.Cells(R_No, 9)
Else
Templ.Range("C11") = Templ.Range("C11") & Templ.Range("I2") & Combo.Cells(R_No, 2)
Templ.Range("D11") = Templ.Range("D11") & Templ.Range("I2") & Combo.Cells(R_No, 3)
Templ.Range("E11") = Templ.Range("E11") & Templ.Range("I2") & Combo.Cells(R_No, 5)
Templ.Range("F11") = Templ.Range("F11") & Templ.Range("I2") & Combo.Cells(R_No, 6)
Templ.Range("G11") = Templ.Range("G11") & Templ.Range("I2") & Combo.Cells(R_No, 9)
End If
End If
If Combo.Cells(R_No, 1) = "Receipt" Then
Rows("13:14").Select
Selection.EntireRow.Hidden = False
If Templ.Range("C14") = "" Then
Templ.Range("C14") = Combo.Cells(R_No, 2) & "-" & Combo.Cells(R_No, 4)
Templ.Range("D14") = Combo.Cells(R_No, 3)
Templ.Range("E14") = Combo.Cells(R_No, 5)
Temp1.Range("F14") = Combo.Cells(R_No, 6)
Temp1.Range("G14") = Combo.Cells(R_No, 9)
Else
Templ.Range("C14") = Templ.Range("C14") & Templ.Range("I2") & Combo.Cells(R_No, 2) & "-" & Combo.Cells(R_No, 4)
Templ.Range("D14") = Templ.Range("D14") & Templ.Range("I2") & Combo.Cells(R_No, 3)
Templ.Range("E14") = Templ.Range("E14") & Templ.Range("I2") & Combo.Cells(R_No, 5)
Templ.Range("F14") = Templ.Range("F14") & Templ.Range("I2") & Combo.Cells(R_No, 6)
Templ.Range("G14") = Templ.Range("G14") & Templ.Range("I2") & Combo.Cells(R_No, 9)
End If
End If
End If
Else
If Combo.Cells(R_No, 1) = "Order" Then
Rows("10:11").Select
Selection.EntireRow.Hidden = False
If Templ.Range("C11") = "" Then
Templ.Range("C11") = Combo.Cells(R_No, 2)
Templ.Range("D11") = Combo.Cells(R_No, 3)
Templ.Range("E11") = Combo.Cells(R_No, 5)
Temp1.Range("F11") = Combo.Cells(R_No, 6)
Temp1.Range("G11") = Combo.Cells(R_No, 9)
Else
Templ.Range("C11") = Templ.Range("C11") & Templ.Range("I2") & Combo.Cells(R_No, 2)
Templ.Range("D11") = Templ.Range("D11") & Templ.Range("I2") & Combo.Cells(R_No, 3)
Templ.Range("E11") = Templ.Range("E11") & Templ.Range("I2") & Combo.Cells(R_No, 5)
Templ.Range("F11") = Templ.Range("F11") & Templ.Range("I2") & Combo.Cells(R_No, 6)
Templ.Range("G11") = Templ.Range("G11") & Templ.Range("I2") & Combo.Cells(R_No, 9)
End If
End If
If Combo.Cells(R_No, 1) = "Receipt" Then
Rows("13:14").Select
Selection.EntireRow.Hidden = False
If Templ.Range("C14") = "" Then
Templ.Range("C14") = Combo.Cells(R_No, 2) & "-" & Combo.Cells(R_No, 4)
Templ.Range("D14") = Combo.Cells(R_No, 3)
Templ.Range("E14") = Combo.Cells(R_No, 5)
Temp1.Range("F14") = Combo.Cells(R_No, 6)
Temp1.Range("G14") = Combo.Cells(R_No, 9)
Else
Templ.Range("C14") = Templ.Range("C14") & Templ.Range("I2") & Combo.Cells(R_No, 2) & "-" & Combo.Cells(R_No, 4)
Templ.Range("D14") = Templ.Range("D14") & Templ.Range("I2") & Combo.Cells(R_No, 3)
Templ.Range("E14") = Templ.Range("E14") & Templ.Range("I2") & Combo.Cells(R_No, 5)
Templ.Range("F14") = Templ.Range("F14") & Templ.Range("I2") & Combo.Cells(R_No, 6)
Templ.Range("G14") = Templ.Range("G14") & Templ.Range("I2") & Combo.Cells(R_No, 9)
End If
End If
Templ.Range("C6") = "Dear " & Left(Combo.Cells(R_No, 7), InStr(1, Combo.Cells(R_No, 7), " ") - 1) & ","
Templ.Range("A1:H48").Select
ThisWorkbook.EnvelopeVisible = False
ThisWorkbook.EnvelopeVisible = True
With ThisWorkbook.Sheets("Templete").MailEnvelope
.Item.Subject = "Reminder- Order(s) / Receipt(s) Pending Your Urgent Approval"
.Item.To = Combo.Cells(R_No, 8)
.Item.cc = " "
If Combo.Cells(R_No, 10) <> "" Then
.Item.cc = Combo.Cells(R_No, 12)
Else
End If
.Item.Send
Templ.Range("C11") = ""
Templ.Range("D11") = ""
Templ.Range("E11") = ""
Templ.Range("F11") = ""
Templ.Range("G11") = ""
Templ.Range("C14") = ""
Templ.Range("D14") = ""
Templ.Range("E14") = ""
Templ.Range("F14") = ""
Templ.Range("G14") = ""
Rows("10:11").Select
Selection.EntireRow.Hidden = True
Rows("13:14").Select
Selection.EntireRow.Hidden = True
End With
End If
R_No = R_No + 1
Loop
End Sub