Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / August 2005

Tip: Looking for answers? Try searching our database.

Toolbar-Problem

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
pleasesendspamtothisadress@gmx.net - 25 Aug 2005 20:58 GMT
Hello,

In Word97 I create a Toolbar (x=Application.CommandBars.Add) with a
single Button on it (x.Controls.Add). I have further an Add-In
"addin1.dot" in the StartUp-Fodler with a module "Module1" which
contains a procedure "Proc1" itsself. If someone clicks the button the
"Proc1"-procedure should be executed.

Now there is the problem that after the first-time installation of the
toolbar the desired effect doesn't occur in most trials. So I have to
remove the Toolbar, create it again and after several times of doing
this, the Proc1-prodecure is executed. Before there is no action when
the button ic clicked.

By the way: There is no difference if I use >OnAction =
"Module1.Proc1"< or >OnAction = "Proc1"< when creating the toolbar.
Only >OnAction = "addin1.dot!Module1.Proc1"< semms not running
constantly.

Does anybody know why there is such an unpredictable behavior of the
action, so that it sometimes works and often none? What to do that it
works the right way?

Kind Regards,
Nachtigall
Klaus Linke - 27 Aug 2005 12:04 GMT
Hi Nachtigall,

When you click the button, Word needs to know where to look for the macro.

> Only >OnAction = "addin1.dot!Module1.Proc1"< semms not running
> constantly.

Not sure I understand that sentence: Sometimes when you click the button it
works, sometimes not?

Regards,
Klaus
Helmut Weber - 27 Aug 2005 12:57 GMT
Hi everybody

seems to be a bug.
Calling a sub in another addin or so,
doesn't behave like documented.

I was told there was a knowlegdebase article about it,
but can't find it.

Tested with:

Application.Run "SystemwideUniqueModuleName.SubName" ' yes
Application.Run "SystemwideUniqueSubName" ' yes

Application.Run "Project1.module1.SubName" ' no

Ought to be same with "OnAction".

Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"


pleasesendspamtothisadress@gmx.net - 27 Aug 2005 21:06 GMT
Yes, Klaus: After creating the toolbar sometimes it works and sometimes
not after clicking the button.

But note:

If it works after creating, it works as long as you remove the toolbar.

If it does not work after creating, it seems that there is no chance to
set it up unless you try again by deleting and re-creating the toolbar.

Helmut, do you mean, I should  place the  "Application.Run"-expression
in my Add-In, or is it only written for comparison, because as I have
written above I already find out that the OnAction-Tag doesn't work
with "AddIn.dot!Module1.Proc1" but only with "Module1.Proc1" or
"Proc1"...

Regards,
Nachtigall

(soll heissen: Wenn der Button, nachdem die Toolbar hinzugefügt wurde,
nicht funktioniert, geht er frühestens nach einer Neuinstallation der
Toolbar. Geht er hingegen sofort, tut er auch weiterhin. Es scheint
wirklich zufällig zu sein, ob sich VBA dazu "entschließt", den
OnAction-Tag richtig zu setzen, oder nicht.)
Helmut Weber - 27 Aug 2005 21:27 GMT
Hi Nachtigall,

>Yes, Klaus: After creating the toolbar sometimes it works and sometimes
>not after clicking the button.

due to multitasking issues and cache behaviour,
you'll never know,
how much time a task will need to complete.

That's where the random behaviour comes from.

First, as I said, there is a bug in the so documented
syntax for calling subs in other projects.
I've discussed this in public.de.word.vba.

Second, as I said, actions in automacros might fail,
as all components of a doc are ready to use only after
completion of the automacro.

Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"
pleasesendspamtothisadress@gmx.net - 27 Aug 2005 22:54 GMT
Hi Helmut,

Such an behavior seems not to be very satisfactory...

But in the present case there is no time-critical execution (Autoexec
or so) because I could create the toolbar via buttonclick after ten
minutes Word was starting and a click on the button might have no
results because of OnAction-Failure (let's assume that the
OnAction-Expression is used the correct way, because sometimes it
works).

So have I really to accept that the creation of an working toolbar is a
gamble?

Nachtigall
Klaus Linke - 28 Aug 2005 03:23 GMT
Hi Nachtigall,

Do you really have an add-in, or just a global template (with a code module)
in the startup folder?
Have you set the customization context so that the toolbar is created in
your template (not in Normal.Dot)?
If so, why doesn't it suffice to do that once? It sounds as if you add the
toolbar at every startup.

What does OnAction say when the toolbar button doesn't work?
? CommandBars("YourToolBar").Captions("YourMacroButtonCaption").OnAction

Do you have Add-Ins (Adobe Acrobat ...) installed? Does it work if you start
Word with the /a switch?

Gruß,
Klaus

> Hi Helmut,
>
[quoted text clipped - 11 lines]
>
> Nachtigall
pleasesendspamtothisadress@gmx.net - 28 Aug 2005 10:52 GMT
Okay, sorry, no Add-In but a *.dot-File in the StartUp-Path.

For understanding again my proceeding: I first create a permanently
toolbar and button out of a temporary file. Its OnAction-Tag refers to
a Sub written in the *.dot-File which is copiied to the StartUp-Path.

If I am in luck, the OnAction-Tag is set up correctly and every thing
works fine. -> After clicking the button the defined sub is called.

Otherwise the OnAction-Tag seems not to be set up correctly, just
nothing happens after clicking the button. -> As if you have a
dummy-button.

Nachtigall
Klaus Linke - 28 Aug 2005 12:07 GMT
Sorry, still don't get it (probably my fault).

> I first create a permanently toolbar and button out of a temporary file.

Could you say that "auf Deutsch"?

I don't understand why you don't put the toolbar with the button in your
global template (... the *.dot file in the startup path).
And why you want to create/destroy it each time you start Word.
Every toolbar you have in the global template, or every customization to the
built-in toolbars that you have made in it, should be available without
doing anything.

Some COM Add-ins do things like you try to (and usually mess up badly,
changing and dirtying Normal.dot or putting countless buttons on the
built-in toolbars and [context] menus without removing them), but in your
case I still don't get the reason why you'd want to do things that way.

Greetings,
Klaus

<pleasesendspamtothisadress@gmx.net> schrieb:
> Okay, sorry, no Add-In but a *.dot-File in the StartUp-Path.
>
[quoted text clipped - 10 lines]
>
> Nachtigall
pleasesendspamtothisadress@gmx.net - 28 Aug 2005 13:57 GMT
Hallo Klaus,

Ich habe einen Code-Schnipsel, mit dem ich eine Toolbar samt Button
erzeuge. Diese wird daraufhin auch korrekt angezeigt.

Nun habe ich des weiteren eine dot-Datei im StartUp-Verzeichnis, welche
einzig und allein die auszuführende Prozedur beinhaltet; mit dem
Erstellen des Buttons hat diese also nichts zu tun, da dies ja bereits
im Voraus geschehen ist.

Und nun sieht es eben so aus, dass im positiven Fall ein Buttonklick
tatsächlich die Prozedur ausführt. Nach manch anderen Installation
aber passiert bei einem Buttonklick nichts.

Der Grund, wieso ich die Toolbar nicht im GlobalTemplate via Autoexec()
temporär zur Laufzeit erstelle ist der, dass die Toolbar mit dem
Schließen von Word komischerweise nicht verschwindet, obwohl ich
temporary:=True gesetzt habe, und daher bei jedem Öffnen von Word eine
weitere hinzukommt...

Grüße,
Nachtigall
pleasesendspamtothisadress@gmx.net - 29 Aug 2005 20:23 GMT
Somebody an idea?
Klaus Linke - 30 Aug 2005 06:06 GMT
> Der Grund, wieso ich die Toolbar nicht im GlobalTemplate via Autoexec()
> temporär zur Laufzeit erstelle ist der, dass die Toolbar mit dem
> Schließen von Word komischerweise nicht verschwindet, obwohl ich
> temporary:=True gesetzt habe, und daher bei jedem Öffnen von Word eine
> weitere hinzukommt...

Hallo Nachtigall

Das ist nicht die Alternative.
Normal wäre, die Symbolleiste und die Buttons in der globalen Vorlage
anzulegen (nur einmal, manuell oder per Makro ist egal).
AutoExec oder so was brauchst du nicht. Temporär sind die Anpassungen
sowieso (will meinen, sie werden zu den eingebauten Symbolleisten und Menüs
hinzugefügt, wenn du Word startest bzw. die globale Vorlage hinzufügst. Und
wenn du die globale Vorlage entlädst bzw. Word beendest, verschwinden sie
wieder).

Gruß,
Klaus
pleasesendspamtothisadress@gmx.net - 30 Aug 2005 16:24 GMT
Hallo Klaus,

Insofern gibt es dann natürlich zwei verschiedene Ansichten, was man
unter "temporär" verstehen kann...

Wie genau greife ich auf die Globale Vorlage zu? Und was ist der
Unterschied zwischen soclh einer, ein im StartUp-Path abgelegtes
dot-File und ein über das Menü geladenes Add-Inn?

Grüße,
Nachtigall
Klaus Linke - 30 Aug 2005 17:14 GMT
Hi Nachtigall,

A global template is loaded when you start Word, or when you add it in
"Tools > Templates and Add-Ins", and removed when you quit Word or remove it
in the dialog.
Templates in the StartUp paths are global templates and are loaded
automatically. Their advantage is that an administrator can add them without
messing about in Word.

You can customize a global template the same way as you would Normal.dot.
You just have to set the customization context to that template.
If you do it manually: "Tools > Customize, Commands tab > Save in: ..."

Customizations in global templates can be overridden by customizations in
Normal.dot, the attached template and the document.
The global templates are loaded in reverse alphabetic order, so one starting
with "A" overrides one whose name starts with "B".
But if you add some buttons attached to macros (on your own toolbars/menus
or your own), it's very unlikely that another template will mess with them.

Many creators of (COM) Add-Ins have never understood how that's supposed to
work, it seems, and add temporary controls programmatically (as you try to
do) ...
The result is that often they dirty Normal.dot (leading to "Do you want to
save changes to the global template?" when you quit Word), create multiple
buttons and menu items, because they leave them behind if Word crashes, or
after you uninstall the add-in. Often, they also leave behind a global
template in the startup folder, leading to macro error messages every time
you open Word.

:-(  Klaus

Hallo Klaus,

Insofern gibt es dann natürlich zwei verschiedene Ansichten, was man
unter "temporär" verstehen kann...

Wie genau greife ich auf die Globale Vorlage zu? Und was ist der
Unterschied zwischen soclh einer, ein im StartUp-Path abgelegtes
dot-File und ein über das Menü geladenes Add-Inn?

Grüße,
Nachtigall
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.