Keep Losing Custom Template Styles

S

Stefan1000

Hi,

I have recently created a toolbar in Word (via VBA), which allows me to
select specific style or paragraph formatting for my text.

I simply highlight the text and select from the toolbar the style or
format. The toolbar has been saved into a custom template.

However I'm having some very strange results. The toolbar in general
works, however I sometimes recieve the error:

'Style not available in the document'.

I designed the above error to appear, when the toolbar was unable to
find the styles from the custom template. I'm slightly confused.... I
have a number of documents, which are currently attached to this custom
template and I receive the above errors on a regular basis. The
function appears to be very hit and miss.

If I add the custom template, to a new document via Templates &
Add-ins, the error immediately happens. The above error seems to be
the fact that it's losing the connection between the custom template
and the document.

To avoid the error I have to save the document, close and then reopen
the document - before I can pick a style from the toolbar. I'm
assuming the fix above, is refreshing the 'ThisDocument' object, which
allows it to work again.

I was wondering, whether anyone had any ideas - what I may have done
wrong when coding the toolbar.....

Any advice would be greatly appreciated.

Thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top