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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Word VBA - printobject for VB objects

Status
Not open for further replies.

Turpis

Programmer
Apr 16, 2002
151
I am used to working in Excel VBA, but I am currently doing my first major project in Word VBA and I am disappointed to discover that when you put a VB Objects (commandbutton) that the printobject property is not available. I can put buttons all over the place in Excel and they don't print unless I want them too, how can I do this with Word? or...can I assign hotkeys through VBA code?

Charles
Walden's Machine, Inc.
Quality Assurance/Office Developer
 
No suggestions on this?

Charles
Walden's Machine, Inc.
Quality Assurance/Office Developer
 
Hi Charles,

It does seem a little peculiar but buttons in Word documents are an integral part of the document and (by default) flow with the text and generally behave like text or pictures.

If you just want a button to perform a function, a custom toolbar is probably the way forward or, as you suggest, hotkeys. It is certainly possible to assign hotkeys through code. What exactly do you want to do?

Enjoy,
Tony
 
I have a form that allows the user to pick groups of data out of a database and then a document is created for faxing to our material vendors. I have it activate on the open event but if they want to do another they have to close the document at this point and open it again. I have created custom tool bars and such in excel, I just didn't want to do that, would have been nicer if there was a button on the document. How would I (just for fun) assign hotkey to a particular macro, like frmGetFaxData with vb code?

I would like to know for future projects, but I think you are right about the custom toolbar.

Charles
Walden's Machine, Inc.
Quality Assurance/Office Developer
 
Hi Charles,

As I write this it occurs to me that I might have misunderstood, but assuming by hotkeys you mean shortcut keys (and not something like a Mouseover Event) ..

They can be set for documents or templates, and the first thing you must do is set what Word calls the customization context, for example ..

Code:
Customizationcontext = Documents(1)
or ..
Code:
Customizationcontext = NormalTemplate

In context you then add a key binding ..

Code:
KeyBindings.Add _
    KeyCode:=BuildKeyCode(wdKeyY, wdKeyControl), _
    KeyCategory:=wdKeyCategoryMacro, _
    Command:="
Code:
MacroName
Code:
"

There are various key categories corresponding to the different types of things which can be added – see the Tools > Customize… > KeyBoard… dialog to see them all.

Enjoy,
Tony
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top