Why are style updates in VBA not reflected in the document?
Greetings. I have been coding VBA and vb.net for 15 years. I have made dozens of time-saving add-ins, applications, and macros in word, excel, access, and powerpoint. I have a question to which I cannot find an answer. I only wish to know "why".
I do not seek an alternative method for doing this (unless it's easy ;-)). I don't have code to show you. I know all about the virtues and vices of style templates. I do not seek to be chastised for wanting to do something so stupid. I only want to know why something does not work.
OK - with that as the caveat - If I am in a word document and select modify a style, select the font and change it from Arial to Times New Roman, when I am done with the dialogue all the text of that style changes from Arial to Times New Roman in the document text.
If I do the exact same thing in VBA, (find the style from the styles collection and modify the font) the text does not update. I run my code and examine the style in the style manager dialogue box I can see my changes (the font for the style shows Times New Roman), yet the text in the document stubbornly stays Arial. Why?
I can force the update by looping through the paragraph collection and applying the style (!) but I don't want to do that.
I have searched and searched and cannot find an answer to this question. Maybe one of you knows.
|