Controls versus commands?

C

Chuck

We've got a problem with external code where the external developers have
created an add in that intercepts FileSave and FileSaveAs but seems to
disable Ctrl+S to save files ONLY if users have dragged the File SaveAs
command onto a command bar.

Looking at the code in the add in, the external developers have chosen to
bind a command bar control to an object and then execute the object instead
of simply using ActiveDocument.Save or ActiveDocument.SaveAs (or object.save
or whatever).

Question -- what is the rationale for binding an object to a command bar
control (see below) instead of simply using ActiveDocument.Save or
object.Save?

Sub FileSaveBinding()
[snip]
Set objSave = Word.CommandBars("File").FindControl(ID:=3)
objSave.Execute
[snip]
End sub

Sub FileSaveAsBinding()
[snip]
Set objSaveAs = Word.CommandBars("File").FindControl(ID:=748)
objSaveAs.Execute
[snip]
End sub

Note: This is a bit of a repost from a previous thread. (There seemed to
be some confusion in the previous thread about what I was asking -- the
question we're trying to answer here is about coding practice -- why bind an
object to a command bar control and then execute the object rather than
simply using a Save/SaveAs command -- *not* about when/how to use buttons on
command bars.)

Thanks for any thoughts!
 
W

Word Heretic

G'day "Chuck" <[email protected]>,

It is compatible with more versions of Word.

Steve Hudson - Word Heretic

steve from wordheretic.com (Email replies require payment)
Without prejudice


Chuck reckoned:
 
C

Chuck

Thanks Steve. Seems a bit counterintuitive to me to bind to command bar
controls rather than commands (seeing as how the control ID numbers aren't
self-explanatory and could possibly change) but live and learn!

Word Heretic said:
G'day "Chuck" <[email protected]>,

It is compatible with more versions of Word.

Steve Hudson - Word Heretic

steve from wordheretic.com (Email replies require payment)
Without prejudice


Chuck reckoned:
We've got a problem with external code where the external developers have
created an add in that intercepts FileSave and FileSaveAs but seems to
disable Ctrl+S to save files ONLY if users have dragged the File SaveAs
command onto a command bar.

Looking at the code in the add in, the external developers have chosen to
bind a command bar control to an object and then execute the object instead
of simply using ActiveDocument.Save or ActiveDocument.SaveAs (or object.save
or whatever).

Question -- what is the rationale for binding an object to a command bar
control (see below) instead of simply using ActiveDocument.Save or
object.Save?

Sub FileSaveBinding()
[snip]
Set objSave = Word.CommandBars("File").FindControl(ID:=3)
objSave.Execute
[snip]
End sub

Sub FileSaveAsBinding()
[snip]
Set objSaveAs = Word.CommandBars("File").FindControl(ID:=748)
objSaveAs.Execute
[snip]
End sub

Note: This is a bit of a repost from a previous thread. (There seemed to
be some confusion in the previous thread about what I was asking -- the
question we're trying to answer here is about coding practice -- why bind an
object to a command bar control and then execute the object rather than
simply using a Save/SaveAs command -- *not* about when/how to use buttons on
command bars.)

Thanks for any thoughts!
 
W

Word Heretic

G'day "Chuck" <[email protected]>,

Yar - see those button ids havent changed in so many versions of word
it aint funny - whereas everything else has changed :)

Steve Hudson - Word Heretic

steve from wordheretic.com (Email replies require payment)
Without prejudice


Chuck reckoned:
Thanks Steve. Seems a bit counterintuitive to me to bind to command bar
controls rather than commands (seeing as how the control ID numbers aren't
self-explanatory and could possibly change) but live and learn!

Word Heretic said:
G'day "Chuck" <[email protected]>,

It is compatible with more versions of Word.

Steve Hudson - Word Heretic

steve from wordheretic.com (Email replies require payment)
Without prejudice


Chuck reckoned:
We've got a problem with external code where the external developers have
created an add in that intercepts FileSave and FileSaveAs but seems to
disable Ctrl+S to save files ONLY if users have dragged the File SaveAs
command onto a command bar.

Looking at the code in the add in, the external developers have chosen to
bind a command bar control to an object and then execute the object instead
of simply using ActiveDocument.Save or ActiveDocument.SaveAs (or object.save
or whatever).

Question -- what is the rationale for binding an object to a command bar
control (see below) instead of simply using ActiveDocument.Save or
object.Save?

Sub FileSaveBinding()
[snip]
Set objSave = Word.CommandBars("File").FindControl(ID:=3)
objSave.Execute
[snip]
End sub

Sub FileSaveAsBinding()
[snip]
Set objSaveAs = Word.CommandBars("File").FindControl(ID:=748)
objSaveAs.Execute
[snip]
End sub

Note: This is a bit of a repost from a previous thread. (There seemed to
be some confusion in the previous thread about what I was asking -- the
question we're trying to answer here is about coding practice -- why bind an
object to a command bar control and then execute the object rather than
simply using a Save/SaveAs command -- *not* about when/how to use buttons on
command bars.)

Thanks for any thoughts!
 
C

Chuck

Ah, good to know. I was going to ask where I could get a list of the control
id numbers but I found a macro in the MS Knowledgebase that generates a list
(KB article 243988, at
http://support.microsoft.com/default.aspx?scid=kb;en-us;243988).

Word Heretic said:
G'day "Chuck" <[email protected]>,

Yar - see those button ids havent changed in so many versions of word
it aint funny - whereas everything else has changed :)

Steve Hudson - Word Heretic

steve from wordheretic.com (Email replies require payment)
Without prejudice


Chuck reckoned:
Thanks Steve. Seems a bit counterintuitive to me to bind to command bar
controls rather than commands (seeing as how the control ID numbers aren't
self-explanatory and could possibly change) but live and learn!

Word Heretic said:
G'day "Chuck" <[email protected]>,

It is compatible with more versions of Word.

Steve Hudson - Word Heretic

steve from wordheretic.com (Email replies require payment)
Without prejudice


Chuck reckoned:

We've got a problem with external code where the external developers have
created an add in that intercepts FileSave and FileSaveAs but seems to
disable Ctrl+S to save files ONLY if users have dragged the File SaveAs
command onto a command bar.

Looking at the code in the add in, the external developers have chosen to
bind a command bar control to an object and then execute the object instead
of simply using ActiveDocument.Save or ActiveDocument.SaveAs (or object.save
or whatever).

Question -- what is the rationale for binding an object to a command bar
control (see below) instead of simply using ActiveDocument.Save or
object.Save?

Sub FileSaveBinding()
[snip]
Set objSave = Word.CommandBars("File").FindControl(ID:=3)
objSave.Execute
[snip]
End sub

Sub FileSaveAsBinding()
[snip]
Set objSaveAs = Word.CommandBars("File").FindControl(ID:=748)
objSaveAs.Execute
[snip]
End sub

Note: This is a bit of a repost from a previous thread. (There seemed to
be some confusion in the previous thread about what I was asking -- the
question we're trying to answer here is about coding practice -- why bind an
object to a command bar control and then execute the object rather than
simply using a Save/SaveAs command -- *not* about when/how to use buttons on
command bars.)

Thanks for any thoughts!
 

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