编译错误:如果没有阻止,则结束 - 尽管完全阻止,但仍会触发

时间:2018-01-31 16:39:58

标签: excel-vba vba excel

我有一个因为块错误而无法运行的宏。据我所知,该块已完成。当我尝试运行时,Sub LoopThrough Directory()会突出显示为错误,我不太清楚为什么。

Sub LoopThroughDirectory()

Dim MyFile As Variant
Dim wkb As Workbook

Filepath = "\\WFSIADMNSF21\C_MTG_Groups\DAPLAVA\Monthly Vendor Files\Pres\"

MyFile = Dir(Filepath)

Do While Len(MyFile) > 0
    If MyFile <> "PFORMAT.xlsm" Then
        Application.DisplayAlerts = True
        Set wkb = Workbooks.Open(Filepath & MyFile)
        Application.DisplayAlerts = False

**I have 1500 lines of code between here, but no additional if statements, and nothing matches the indentation of the If statement**

  End With
    wkb.Close savechanges:=True
    End If

    MyFile = Dir

Loop
Sheets("PFORMAT").Select

End Sub

0 个答案:

没有答案