April 9, 2024
Contribute to the Microsoft 365 and Office forum!
Click here to learn more 💡
May 10, 2024
Word Forum Top Contributors:
Word 2010 macro error
Report abuse
Thank you.
Reported content has been submitted
Paul Edstein
(Fmr MS MVP - Word)
Report abuse
Thank you.
Reported content has been submitted
Was this reply helpful?
Sorry this didn't help.
Great! Thanks for your feedback.
How satisfied are you with this reply?
Thanks for your feedback, it helps us improve the site.
How satisfied are you with this reply?
Thanks for your feedback.
A procedure starts with "Sub <procedure name> ()" or "Function <procedure name> () As <data type>", and it ends with the matching line "End Sub" or "End Function". Almost everything else must be between those lines, except for lines starting with the words "Dim", "Const", "Public", and a few others.
If you have a line that tries to set a variable's value, or that calls another procedure, and that line isn't between Sub and End Sub, or between Function and End Function, then you get that compile error message.
The usual fix is to move the line inside a procedure where it belongs.
https://jay-freedman.info
Report abuse
Thank you.
Reported content has been submitted
2 people found this reply helpful
·Was this reply helpful?
Sorry this didn't help.
Great! Thanks for your feedback.
How satisfied are you with this reply?
Thanks for your feedback, it helps us improve the site.
How satisfied are you with this reply?
Thanks for your feedback.
Question Info
Last updated October 5, 2021 Views 1,414 Applies to: