Results 1 to 14 of 14
  1. #1
    4 Star Lounger
    Join Date
    Jul 2006
    Posts
    531
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Compile Error - Expected End Sub (2003)

    I am getting an error:

    Compile Error - Expected End Sub

    See attached for details, any help would be appreciated.
    Attached Files Attached Files

  2. #2
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    6,280
    Thanks
    3
    Thanked 191 Times in 177 Posts

    Re: Compile Error - Expected End Sub (2003)

    You can't put an entire Function routine inside a sub. Move it outside and you should be fine.
    Regards,
    Rory

    Microsoft MVP - Excel

  3. #3
    4 Star Lounger
    Join Date
    Jul 2006
    Posts
    531
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Compile Error - Expected End Sub (2003)

    I done that but now l get error, see attached.

    Any ideas as to how l resolve error?
    Attached Images Attached Images

  4. #4
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    6,280
    Thanks
    3
    Thanked 191 Times in 177 Posts

    Re: Compile Error - Expected End Sub (2003)

    You also have a spare <code>End Function</code> line near the end of the sub.
    Regards,
    Rory

    Microsoft MVP - Excel

  5. #5
    4 Star Lounger
    Join Date
    Jul 2006
    Posts
    531
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Compile Error - Expected End Sub (2003)

    I could not see it, please can you send me screenshot of what you mean.

  6. #6
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    6,280
    Thanks
    3
    Thanked 191 Times in 177 Posts

    Re: Compile Error - Expected End Sub (2003)

    The last 2 lines in the code you posted were:
    <pre>End Function

    End Sub
    </pre>

    you need to remove the <code>End Function</code>.
    Regards,
    Rory

    Microsoft MVP - Excel

  7. #7
    4 Star Lounger
    Join Date
    Jul 2006
    Posts
    531
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Compile Error - Expected End Sub (2003)

    You appear to have the wrong code, attached is the correct code.

    If you can resolve the error please can you send the code back to me and highlight the area where it needs to be amended.
    Attached Files Attached Files

  8. #8
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    6,280
    Thanks
    3
    Thanked 191 Times in 177 Posts

    Re: Compile Error - Expected End Sub (2003)

    I have the code you posted - I'm not sure what code you expected me to have! Your problem is this line:
    <code>SigString = "Cocuments and Settings" & Environ("Jbloggs") & _
    "Application DataMicrosoftSignaturessig.txt"</code>
    which evaluates to <code>""</code> because it should be <code>Environ("username") </code>
    Regards,
    Rory

    Microsoft MVP - Excel

  9. #9
    4 Star Lounger
    Join Date
    Jul 2006
    Posts
    531
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Compile Error - Expected End Sub (2003)

    I tried changing username and signature both to a valid name , but still got error. If you try this for yourself you will see what l mean.

  10. #10
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    6,280
    Thanks
    3
    Thanked 191 Times in 177 Posts

    Re: Compile Error - Expected End Sub (2003)

    You misunderstand me - the code should have been exactly what I said - you don't change the <code>"username"</code> bit at all:
    <pre>SigString = "Cocuments and Settings" & Environ("username") & _
    "Application DataMicrosoftSignaturessig.txt"
    </pre>

    Regards,
    Rory

    Microsoft MVP - Excel

  11. #11
    4 Star Lounger
    Join Date
    Jul 2006
    Posts
    531
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Compile Error - Expected End Sub (2003)

    Still get error, any ideas as to what is causing it?
    see code attached
    Attached Files Attached Files

  12. #12
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    6,280
    Thanks
    3
    Thanked 191 Times in 177 Posts

    Re: Compile Error - Expected End Sub (2003)

    There's a line continuation character that shouldn't be there - see attached version.
    Attached Files Attached Files
    Regards,
    Rory

    Microsoft MVP - Excel

  13. #13
    4 Star Lounger
    Join Date
    Jul 2006
    Posts
    531
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Compile Error - Expected End Sub (2003)

    Thatís great many thanks . The only bit which does not work now is sending the current active spreadsheet as an attachment. If you see the code this bit is commented. As l am not that much of an expert on VB l am unsure as to why this is working.
    Attached Files Attached Files

  14. #14
    Silver Lounger
    Join Date
    Jul 2001
    Location
    Ottawa, Ontario, Canada
    Posts
    1,609
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Compile Error - Expected End Sub (2003)

    It strikes me that you are not taking advantage of the VBE Compile capability
    Attached Images Attached Images
    Regards
    Don

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •