0
我在執行多次代碼後收到一行代碼錯誤。它發生在達到相同的執行級別時(宏在試圖完成的目標中的相同位置)。整體計劃旨在生成多個電子郵件並將它們發送給具有不同電子郵件附件的不同公司。它的工作原理直到達到大約2/3rds的位置,我得到了1004的錯誤。有任何想法嗎? **是錯誤的位置。下面的代碼是一個更大規模的小程序。多次執行後If語句出錯
謝謝!
'sets row_counter = row_num to avoid iteration over unecessary rows in ReportsbyFirm and resets continue to True for PDF attachment phase
continue = True
row_counter = row_num
With outMail
.To = firmEmail
.Subject = reportDate
.body = body
Do While continue = True
** If reportsByFirm.Cells(row_counter, firmcol) = cFirm Or reportsByFirm.Cells(row_counter, firmcol) = iFirm Then
pdfLocation = getPDFs(cFirm, iFirm, row_counter, reportsByFirm, trMaster, trSeparate, trName, reportDate)
.Attachments.Add (pdfLocation)
row_counter = row_counter + 1
ElseIf row_counter <> lRowReportsByFirm Then
row_counter = row_counter + 1
Else
continue = False
End If
Loop
.Display
End With
「row_counter」,「firmcol」何時失效,值是多少? –
@TimWilliams公司列固定爲5,row_counter爲28. LRowReportsByFirm在這種情況下是34 – StormsEdge
錯誤的文本是什麼,並且這些單元格中的任何一個是否包含錯誤值? –