Word 2010 macro error

I have been trying to create macros using a text file that has been created by another user.  I have had several errors but the current one is "Compile error: Invalid outside procedure."  I am not comfortable using VBA so any assistance would be great.
Without seeing your code, it's impossible to provide a solution. Even so, the implication is that you're trying to do something outside a Sub or Function than can only be done inside one.
Cheers
Paul Edstein
(Fmr MS MVP - Word)

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.

Expanding on macropod's response a bit:

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

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: