Confirmed: Also happens in MS Word 2010, 2013, 2016 all 64 bit Office*1
*1 I suspect this applies to most of, if not all, the 64 bit office applications
This seems to be an issue with the 64 bit version of MS Office. In the 32 bit version the caret ^
is used for the power operator, however in the 64 bit operator it is also used for variables of type LongLong (docs.microsoft.com/.../vba/.../longlong-data-type).
In 64 bit VBA, when using Debug.Print
*2 the IDE auto corrects 2^2
to 2^; 2
but 2 ^2
is auto-corrected to 2 ^ 2
; making the code compile-able.
By way of a solution, this is just one of those annoying things that users of 64bit VBA 'just need to know'.
Edit: Microsoft confirmed issue https://support.microsoft.com/en-gb/help/2454019/the-64-bit-office-2010-vba-compiler-shows-an-error-when-it-encounters
*2 I've also come to learn that the VBA behavior is different when using debug.Print
than assigning a variable (thanks to @ErikvonAsmuth)