Expected End Sub Error

Michael Propp 1 Reputation point

I have an odd Expected End Sub error that is occurring.
The macro below is activated manually by a button and it is in a workbook that is shared by multiple people.
When I run macro on my computer, it runs fine. When a coworker runs the macro, it has gives the following error:
Compile error: Expected End Sub

I don't know why this is occurring and I can't duplicate it on my computer.

Public Sub AutoPDF()
Dim strPath As String
Dim strName As String
Dim myFile As Variant
Dim wbA As Workbook
Dim strPathName As String

Set wbA = ActiveWorkbook

Worksheets("FS").Visible = xlSheetHidden
Worksheets("Minutes").Visible = xlSheetHidden

strPath = wbA.Path & "\"
strName = wbA.Name & ".pdf"
strPathName = strPath & strName

myFile = Application.GetSaveAsFilename(InitialFileName:=strPathName, fileFilter:="PDF Files (*.pdf), *.pdf", Title:="Select Folder and File Name to Save")

If myFile <> "false" Then
    wbA.ExportAsFixedFormat _
        Type:=xlTypePDF, _
        Filename:=myFile, _
        Quality:=xlQualityStandard, _
        IncludeDocProperties:=True, _
        IgnorePrintAreas:=False, _
End If

Worksheets("FS").Visible = xlSheetVisible
Worksheets("Minutes").Visible = xlSheetVisible

End Sub
{count} votes

1 answer

Sort by: Most helpful
  1. Peter N Roth 1 Reputation point

    MichaelPropp-3388 –
    When you say ‘shared’, do you mean everyone uses one and the same workbook on one and the same machine?
    Everyone has their own copy on separate machines, generated from a single source?

    Go to the errant machine, open the module, look intensely at the End Sub line. Has it been altered? Delete the line. Add an empty line, and type in a new End Sub.
    What happens?