作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
给出标准编译错误“End WIth without With”msgbox。我刚刚开始vba编码。请给我一些指示,让我前进。 (由于代码已插入,制表符出错了。请不要为此烦恼。)
我已经检查了 IF 语句、对象正确性、包含的循环。
'*2/B. - Generate template based new excel file and fill up cells with data of document attributes*
For n = 1 To documentCount
Dim strTemplate As String: strTemplate = "C:\Users\C3642\Desktop\FU5504-Elfogadhatosagi_Nyilatkozat_formanyomtatvany\PA2-FU-5504-NY-01_v2.xlsx"
Set outXl = xlApp.Workbooks.Open(strTemplate, True)
Set outXl = ActiveWorkbook
With outXl.Worksheets(1)
.SaveAs Filename:="C:\Users\C3642\Desktop\FU5504-Elfogadhatosagi_Nyilatkozat_formanyomtatvany\" & docCode(n) & "_" & docResponsible(n) & ".xlsx", FileFormat:=xlOpenXMLWorkbookMacroEnabled
.Cells(5, 4).Value = docName(n)
.Cells(6, 4).Value = docCode(n)
'.Cells(6, 13).Value = docRevision(n) <- nincs hozzá adat :(
.Cells(14, 4).Value = docResponsible(n)
If departmentHead(n) = "Name1" Then
.Cells(14, 7).Value = "VIO"
.Cells(31, 7).Value = "VIO"
.Cells(31, 4).Value = departmentHead(n)
If departmentHead(n) = "Name2" Then
.Cells(14, 7).Value = "ITO"
.Cells(31, 7).Value = "ITO"
.Cells(31, 4).Value = departmentHead(n)
If departmentHead(n) = "Name3" Then
.Cells(14, 7).Value = "VSKO"
.Cells(31, 7).Value = "VSKO"
.Cells(31, 4).Value = departmentHead(n)
If departmentHead(n) = "Name4" Then
.Cells(14, 7).Value = "AMO"
.Cells(31, 7).Value = "AMO"
.Cells(31, 4).Value = departmentHead(n)
If departmentHead(n) = "Name5" Then
.Cells(14, 7).Value = "NUO"
.Cells(31, 7).Value = "NUO"
.Cells(31, 4).Value = departmentHead(n)
If departmentHead(n) = "Name6" Then
.Cells(14, 7).Value = "KGO"
.Cells(31, 7).Value = "KGO"
.Cells(31, 4).Value = departmentHead(n)
If departmentHead(n) = "Name7" Then
.Cells(14, 7).Value = "PGO"
.Cells(31, 7).Value = "PGO"
.Cells(31, 4).Value = departmentHead(n)
If departmentHead(n) = "Name8" Then
.Cells(14, 7).Value = "ETO"
.Cells(31, 7).Value = "ETO"
.Cells(31, 4).Value = departmentHead(n)
If departmentHead(n) = "Name9" Then
.Cells(14, 7).Value = "GMDO"
.Cells(31, 7).Value = "GMDO"
.Cells(31, 4).Value = departmentHead(n)
If departmentHead(n) = "Name10" Then
.Cells(14, 7).Value = "ABO"
.Cells(31, 7).Value = "ABO"
.Cells(31, 4).Value = departmentHead(n)
Else
.Cells(14, 7).Value = ""
.Cells(31, 7).Value = ""
.Cells(31, 4).Value = ""
'.Cells(31, 4).Value = supervisorName(n)
'.Cells(31, 7).Value = supervisorDepartment(n)
.Cells(33, 4).Value = "Name0"
Dim innerReviewers() As String: Dim split_ETO_reviewers() As String: Dim split_KGO_reviewers() As String: Dim split_PGO_reviewers() As String: Dim split_NUO_reviewers() As String
Dim split_AMO_reviewers() As String: Dim split_VSKO_reviewers() As String: Dim split_VIO_reviewers() As String: Dim split_ABO_reviewers() As String: Dim split_ITO_reviewers() As String
Dim split_UIG_reviewers() As String: Dim split_ENBO_reviewers() As String: Dim split_LETO_reviewers() As String: Dim split_Non_ERBE_reviewers() As String: Dim split_ERBE_reviewers() As String
innerReviewers() = Split(reviewers(n), ",")
split_ETO_reviewers() = Split(ETO_reviewers(n), ",")
split_KGO_reviewers() = Split(KGO_reviewers(n), ",")
split_PGO_reviewers() = Split(PGO_reviewers(n), ",")
split_NUO_reviewers() = Split(NUO_reviewers(n), ",")
split_AMO_reviewers() = Split(AMO_reviewers(n), ",")
split_VSKO_reviewers() = Split(VSKO_reviewers(n), ",")
split_VIO_reviewers() = Split(VIO_reviewers(n), ",")
split_ABO_reviewers() = Split(ABO_reviewers(n), ",")
split_ITO_reviewers() = Split(ITO_reviewers(n), ",")
split_UIG_reviewers() = Split(UIG_reviewers(n), ",")
split_ENBO_reviewers() = Split(ENBO_reviewers(n), ",")
split_LETO_reviewers() = Split(LETO_reviewers(n), ",")
split_Non_ERBE_reviewers() = Split(Non_ERBE_reviewers(n), ",")
split_ERBE_reviewers() = Split(ERBE_reviewers(n), ",")
reviewersCount = 0
If IsEmpty(innerReviewers) Or (IsEmpty(innerReviewers) & IsEmpty(split_ETO_reviewers) & IsEmpty(split_KGO_reviewers) & IsEmpty(split_PGO_reviewers) & IsEmpty(split_NUO_reviewers) & IsEmpty(split_AMO_reviewers) & IsEmpty(split_VSKO_reviewers) & IsEmpty(split_VIO_reviewers) & IsEmpty(split_ABO_reviewers) & IsEmpty(split_ITO_reviewers)) Then
MsgBox "The current document has not been reviewed by colleques! (Archiving function of list of non-reviewed docs is not ready.)", vbOKOnly, "Warning for lacking reviewers!"
Else
reviewersCount = UBound(innerReviewers) - LBound(innerReviewers) + 1
Dim i As Integer
i = 0
Do While (i < reviewersCount & i < 12)
.Cells(15 + i, 4).Value = innerReviewers(i)
i = i + 1
Loop
reviewersCount = reviewersCount + UBound(split_ETO_reviewers) - LBound(split_ETO_reviewers) + 1
Do While (i < (12 - reviewersCount))
.Cells(15 + i, 4).Value = ETO_reviewers(i)
i = i + 1
Loop
reviewersCount = reviewersCount + UBound(split_KGO_reviewers) - LBound(split_KGO_reviewers) + 1
Do While (i < (12 - reviewersCount))
.Cells(15 + i, 4).Value = KGO_reviewers(i)
i = i + 1
Loop
reviewersCount = reviewersCount + UBound(split_PGO_reviewers) - LBound(split_PGO_reviewers) + 1
Do While (i < (12 - reviewersCount))
.Cells(15 + i, 4).Value = PGO_reviewers(i)
i = i + 1
Loop
reviewersCount = reviewersCount + UBound(split_NUO_reviewers) - LBound(split_NUO_reviewers) + 1
Do While (i < (12 - reviewersCount))
.Cells(15 + i, 4).Value = NUO_reviewers(i)
i = i + 1
Loop
reviewersCount = reviewersCount + UBound(split_AMO_reviewers) - LBound(split_AMO_reviewers) + 1
Do While (i < (12 - reviewersCount))
.Cells(15 + i, 4).Value = AMO_reviewers(i)
i = i + 1
Loop
reviewersCount = reviewersCount + UBound(split_VSKO_reviewers) - LBound(split_VSKO_reviewers) + 1
Do While (i < (12 - reviewersCount))
.Cells(15 + i, 4).Value = VSKO_reviewers(i)
i = i + 1
Loop
reviewersCount = reviewersCount + UBound(split_VIO_reviewers) - LBound(split_VIO_reviewers) + 1
Do While (i < (12 - reviewersCount))
.Cells(15 + i, 4).Value = VIO_reviewers(i)
i = i + 1
Loop
reviewersCount = reviewersCount + UBound(split_ABO_reviewers) - LBound(split_ABO_reviewers) + 1
Do While (i < (12 - reviewersCount))
.Cells(15 + i, 4).Value = ABO_reviewers(i)
i = i + 1
Loop
reviewersCount = reviewersCount + UBound(split_ITO_reviewers) - LBound(split_ITO_reviewers) + 1
Do While (i < (12 - reviewersCount))
.Cells(15 + i, 4).Value = ITO_reviewers(i)
i = i + 1
Loop
reviewersCount = reviewersCount + UBound(split_UIG_reviewers) - LBound(split_UIG_reviewers) + 1
Do While (i < (12 - reviewersCount))
.Cells(15 + i, 4).Value = UIG_reviewers(i)
i = i + 1
Loop
reviewersCount = reviewersCount + UBound(split_ENBO_reviewers) - LBound(split_ENBO_reviewers) + 1
Do While (i < (12 - reviewersCount))
.Cells(15 + i, 4).Value = ENBO_reviewers(i)
i = i + 1
Loop
reviewersCount = reviewersCount + UBound(split_LETO_reviewers) - LBound(split_LETO_reviewers) + 1
Do While (i < (12 - reviewersCount))
.Cells(15 + i, 4).Value = LETO_reviewers(i)
i = i + 1
Loop
'reviewersCount = reviewersCount + UBound(split_Non_ERBE_reviewers) - LBound(split_Non_ERBE_reviewers) + 1
'Do While (i < (12 - reviewersCount))
' .Cells(15 + i, 4).Value = Non_ERBE_reviewers(i)
' i = i + 1
'Loop
'reviewersCount = reviewersCount + UBound(split_ERBE_reviewers) - LBound(split_ERBE_reviewers) + 1
'Do While (i < (12 - reviewersCount))
' .Cells(15 + i, 4).Value = ERBE_reviewers(i)
' i = i + 1
'Loop
End With
outXl.Close SaveChanges:=True
Next n
也许 Workbook 对象设置不正确(但它在我的代码中声明)。
最佳答案
出现错误,因为到处都缺少 End If
。
例如:
If departmentHead(n) = "Name3" Then
.Cells(14, 7).Value = "VSKO"
.Cells(31, 7).Value = "VSKO"
.Cells(31, 4).Value = departmentHead(n)
End If
关于excel - 标准,但特定 "End With without With"编译错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57856193/
我是一名优秀的程序员,十分优秀!