Discussion:
Macro not responding to button-click event
(too old to reply)
Meena Bhashyam
2005-04-22 20:04:04 UTC
Permalink
Hi,
I have a number of macros that I added to word, through the following code:

objWordDoc.VBProject.VBComponents.Import fileName

One of these macros is FileSave, which should be called when the user clicks
on the Save button. This does not seem to get called the first time the user
clicks, but gets called the next time.

I am not really sure why this is so. Any help would be appreciated.
Thank you,
Meena
Cindy M -WordMVP-
2005-04-24 10:56:01 UTC
Permalink
Hi =?Utf-8?B?TWVlbmEgQmhhc2h5YW0=?=,
Post by Meena Bhashyam
objWordDoc.VBProject.VBComponents.Import fileName
One of these macros is FileSave, which should be called when the user clicks
on the Save button. This does not seem to get called the first time the user
clicks, but gets called the next time.
I am not really sure why this is so.
The code may not have been compiled immediately after the import, so Word
doesn't "see" it, yet. I often see this when I first create a procedure using a
built-in command name; I have to explicitly run the procedure once to make Word
"aware" of it.

You might have your code explicitly call these procs. Set a global variable
that the procs check to find out whether they should fully execute, or skip the
main portion of the code, so that the user isn't aware of them.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or reply
in the newsgroup and not by e-mail :-)
Meena Bhashyam
2005-04-25 13:53:03 UTC
Permalink
Cindy,
Thank you. I now realize what was going on. I tried saving the document once
within the code, that seemed to help.
Meena
Post by Cindy M -WordMVP-
Hi =?Utf-8?B?TWVlbmEgQmhhc2h5YW0=?=,
Post by Meena Bhashyam
objWordDoc.VBProject.VBComponents.Import fileName
One of these macros is FileSave, which should be called when the user clicks
on the Save button. This does not seem to get called the first time the user
clicks, but gets called the next time.
I am not really sure why this is so.
The code may not have been compiled immediately after the import, so Word
doesn't "see" it, yet. I often see this when I first create a procedure using a
built-in command name; I have to explicitly run the procedure once to make Word
"aware" of it.
You might have your code explicitly call these procs. Set a global variable
that the procs check to find out whether they should fully execute, or skip the
main portion of the code, so that the user isn't aware of them.
Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)
http://www.word.mvps.org
This reply is posted in the Newsgroup; please post any follow question or reply
in the newsgroup and not by e-mail :-)
Loading...