Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Word add-in asks for save on close 1

Status
Not open for further replies.

Nelviticus

Programmer
Sep 9, 2003
1,819
GB
Hi there,

I've created an add-in for Word which is just a template called 'Toolbar.dot' that's going to be placed in the Word startup folder. It contains a few macros and a toolbar for launching them. In addition to other functionality the macros change the state of the toolbar - i.e. when you click the 'memo' button, the code sets the button's 'state' to 'msoButtonDown' so that the button looks clicked.

However, when the user quits Word they are asked whether or not they want to save changes to the Toolbar.dot. Is there any way to avoid this? I've tried adding the code
Code:
Documents("Toolbar.dot").Saved = True
to the events but it seems to have no effect. Any changes I make have to be in Toolbar.dot rather than in Word's settings because it has to be rolled out to a lot of users.

Thanks

Nelviticus
 
Why have the button appearance change? Seems a little cute, and not particularly useful. In any case, the file IS changed and as it is the template file that changes Word will ask if you want to save it. You can say that it is saved, but if it really is not.....

Gerry
 
Hi Nelviticus,

I think Gerry's being a bit harsh - changing button states just makes your buttons behave like some of Word's own. It does, as you have found out, however, change the addin.

I'm surprised Documents("Toolbar.dot") doesn't generate an error as a global template isn't open as a document and doesn't belong to the Documents collection. You should be able to sort it by using
Code:
[blue]ThisDocument.Saved = True[/blue]

Enjoy,
Tony

--------------------------------------------------------------------------------------------
We want to help you; help us to do it by reading this: Before you ask a question.
Excel VBA Training and more Help at VBAExpress[
 
Harsh? Hmmmm. I don't see why. Just an opinion, that's all. In Word, yes there is that cuteness of the button looking like it is pressed in. I think THAT is cute as well, and not particularly useful either. However, Word's buttons - if I may point out - do not STAY in, which seems reasonable (even if still "cute"). In this case, by making msoButtonDown = True, the button stays down. And my point is...what IS the point of that? Particularly as it does affect the saved status of the template file. The template file is changed, and for what end? Now you have to add functionality that is, essentially, in response to a NON-functional action.

Tony, correct me if I am wrong, but are there ANY Word buttons that change state, that do NOT revert back - like this one does? If not, then the suggested relationship to Word's buttons is weak. Alternatively you could have the button change state back again - since, IMHO it is kind of pointless anyway. However, I think, you would still have the save problem, as the file HAD changed.

Must ask. You are not actually opening toolbars.dot itself, as a file, are you? If you are, then of course "toolbars.dot" would, in fact, be part of the Documents collection, and you would not get the error Tony mentions. Further to that, if you are...then this is not how templates are supposed to be used, at all.

So, are you opening toolbars.dot itself?

Gerry
 
Gerry said:
Tony, correct me if I am wrong, but are there ANY Word buttons that change state, that do NOT revert back - like this one does?

Bold, Italic, Underline, Align Left, Center, Align Right, Justify ... [wink]


Regards,
Mike
 
Of course. I always forget about those formatting thingies, as I never ever use them. I do not even have the toolbar displayed. I use styles. Dumb me.

Gerry
 
Gerry NOT using STYLES !
Let me die of laughing ... [laughtears]
 
fumei said:
Harsh? Hmmmm. I don't see why.

OK - perhaps harsh was a bit harsh :)

Button states are a bit cute but can be useful; they can indicate a state of something else which may or may not be otherwise obvious. Sometimes button states can be changed, sometimes icons, sometimes text ("Pause Recording" can change to "Resume Recording" for example), or visibility, or enablement - all can be useful and all change the addin - the request didn't seem unreasonable to me.

Enjoy,
Tony

--------------------------------------------------------------------------------------------
We want to help you; help us to do it by reading this: Before you ask a question.
Excel VBA Training and more Help at VBAExpress[
 
And within context....my apologies...of course it was not unreasonable.

Gerry
 
Crikey, I go away for the weekend and look what happens! Thanks everyone for posting [smile]

The buttons in Toolbar.dot are for loading/unloading other add-ins which contain their own toolbars and macros. The reason they are supposed to stay 'clicked down' is that they're a bit like Word's own 'drawing' and 'tables & borders' buttons - i.e. they do nothing themselves except show/hide other toolbars.

Not having them 'clicked in' would solve the immediate problem but the whole point of this exercise is to duplicate some existing functionality to make it easier for our IT Operations team to roll out new machines. At the moment, the toolbars and code that I'm putting into Toolbars.dot has to be manually copied into Normal.dot when a machine is set up.

That's fine if it's a new machine as I could just create a custom Normal.dot, but frequently this has to be applied to an existing machine which already has code in Normal.dot so it can't just be replaced.

Hence my idea for an add-in. I will try Tony's suggestion of 'ThisDocument.Saved = True' but I think I've already tried it. If I remember correctly it just set the currently-edited document to 'saved' rather than the add-in, but maybe I'm getting mixed up.

I should add that the toolbars will mainly be used by our secretaries, and if there's one thing they don't like it's change. That's one of the reasons I'm trying to maintain the 'clicked-in' effect.

Regards

Nelviticus
 
P.S. - in response to fumei's question, no I'm not opening Toolbars.dot itself. It will be placed in <user profile>\Application Data\Microsoft\Word\Startup.

Regards

Nelviticus
 
Thanks Tony, I was wrong - I hadn't tried that before, I just thought I had. It worked.

Regards

Nelviticus
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top