Word VBA OverFlow Error When Multiplying/Adding Integers
It might have occurred to you when working with integers in VBA for Word that you get the following error:
This error generally occurs when you are doing arithmetic operations on integer values that result in:
- Values larger than 32767
- Values smaller than -32768
This is because integers only accept values in the range [-32768, 32767]. Numbers larger than 32767 or smaller than -32768 must be stored in a Long variable. In some office applications this conversion is done implicitly (i.e VBA for Excel). In VBA for word the conversion must be done explicitly.
All the following codes will result in an error: