Recorded macro causing syntax error

%3CLINGO-SUB%20id%3D%22lingo-sub-1528354%22%20slang%3D%22en-US%22%3ERecorded%20macro%20causing%20syntax%20error%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1528354%22%20slang%3D%22en-US%22%3E%3CP%3EI%20record%20a%20macro%20in%20Word%20(Office%20365%20single%20user).%26nbsp%3B%3C%2FP%3E%3CP%3EWhen%20I%20run%20the%20macro%20it%20provokes%20a%20syntax%20error%20in%20VBasic.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20macro%20replaces%20all%20occurrences%20of%20a%20%5Bfull%20stop%20(period)%20followed%20by%20end-of-line%5D%20with%20a%20%5Bfull%20stop%20followed%20by%20vertical%20bar%5D.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIn%20other%20words%20replace%20.%5Ep%20with%20.%7C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EOffice%20translates%20this%20into%20the%20following%20snippet%20of%20VBasic%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ESub%20inline()%3C%2FP%3E%3CP%3E'%3C%2FP%3E%3CP%3E'%20inline%20Macro%3C%2FP%3E%3CP%3E'%3C%2FP%3E%3CP%3E'%3C%2FP%3E%3CP%3ESelection.Find.ClearFormatting%3C%2FP%3E%3CP%3ESelection.Find.Replacement.ClearFormatting%3C%2FP%3E%3CP%3EWith%20Selection.Find%3C%2FP%3E%3CP%3E.Text%20Dialog%20%22.%22%3C%2FP%3E%3CP%3E.Replacement.Text%20Dialog%20%22%22%26nbsp%3B%20%26lt%3B%20this%20provokes%20Microsoft%20Visual%20Basic%20compile%20error%20syntax%20error%3C%2FP%3E%3CP%3E.Forward%20Dialog%20True%3C%2FP%3E%3CP%3E.Wrap%20Dialog%20wdFindContinue%3C%2FP%3E%3CP%3E.Format%20Dialog%20False%3C%2FP%3E%3CP%3E.MatchCase%20Dialog%20False%3C%2FP%3E%3CP%3E.MatchWholeWord%20Dialog%20False%3C%2FP%3E%3CP%3E.MatchWildcards%20Dialog%20False%3C%2FP%3E%3CP%3E.MatchSoundsLike%20Dialog%20False%3C%2FP%3E%3CP%3E.MatchAllWordForms%20Dialog%20False%3C%2FP%3E%3CP%3EEnd%20With%3C%2FP%3E%3CP%3ESelection.Find.ClearFormatting%3C%2FP%3E%3CP%3ESelection.Find.Replacement.ClearFormatting%20...%20etc%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EDo%20you%20know%20how%20to%20fix%20this%3F%3C%2FP%3E%3CP%3EIt%20worked%20perfectly%20on%20all%20previous%20editions%20of%20Word.%20I%20installed%20Office%20365%20yesterday%20and%20note%20that%20it%20wiped%20out%20ALL%20my%20recorded%20macros.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1528354%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EOffice%20365%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Highlighted
Occasional Visitor

I record a macro in Word (Office 365 single user). 

When I run the macro it provokes a syntax error in VBasic.

 

The macro replaces all occurrences of a [full stop (period) followed by end-of-line] with a [full stop followed by vertical bar].

 

In other words replace .^p with .|

 

Office translates this into the following snippet of VBasic:

 

Sub inline()

'

' inline Macro

'

'

Selection.Find.ClearFormatting

Selection.Find.Replacement.ClearFormatting

With Selection.Find

.Text Dialog "."

.Replacement.Text Dialog ""  < this provokes Microsoft Visual Basic compile error syntax error

.Forward Dialog True

.Wrap Dialog wdFindContinue

.Format Dialog False

.MatchCase Dialog False

.MatchWholeWord Dialog False

.MatchWildcards Dialog False

.MatchSoundsLike Dialog False

.MatchAllWordForms Dialog False

End With

Selection.Find.ClearFormatting

Selection.Find.Replacement.ClearFormatting ... etc

 

Do you know how to fix this?

It worked perfectly on all previous editions of Word. I installed Office 365 yesterday and note that it wiped out ALL my recorded macros.

0 Replies