How to set the style in text string of MS Word via AppleScript?
If you open the Microsoft Word dictionary in Script Editor you will see that a range does not have an attribute format, only an attribute style so the correct line is set style of theRange to style heading1.

After that your code complains that StringVar is not defined so I assume you are setting it before the code you have given us.