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

Word 2007: Call sub in other open document

Status
Not open for further replies.

BrianWen

Programmer
Jun 8, 2009
102
DK
OK, so I have a template (.dotm) in the STARTUP folder. This templates includes a new ribbon with a few buttons. Now, the users are using other templates to create new documents. So they are having the main template opened in the back, providing the buttons and then they are working on a new document from another template.

One of the buttons in the ribbon, needs to call a sub in the template, the activedocument is based on.

How is that done? - I'm not looking for a way to call template.dotx.projectname.modulename.subname or whatever.
I'm trying to call activedocument.projectname.modulename.subname

I realize that's not the correct way, but what is the correct way? :)
 
needs to call a sub in the template, the activedocument is based on."

"I'm not looking for a way to call template.dotx.projectname.modulename.subname or whatever.
I'm trying to call activedocument.projectname.modulename.subname"

Which is it? You state you need to call a sub in the template, then state you do not want to call a sub in the template.

"I realize that's not the correct way, but what is the correct way? :) "

the correct way to do what???

Gerry
 
I'm not looking for a way to call template.dotx.projectname.modulename.subname or whatever.I'm trying to call activedocument.projectname.modulename.subname"

By this i simply mean that I want to open a sub in an already open document/template and not by providing VBA with a filename for a not open file.

So, to summarize: One template, t1, is loaded at startup and provides a few subs tied to buttons in a new tab.
Actual document is based on another template (t2). When clicking tab button launching sub in t1, the VBA in that sub should launch sub in t2.

Hope you understand.
 
Normally a firing mechanism is tied to the the document/template it is gebnerated from.

Template_A has a firing mechanism (keyboard shortcut, menu in older vesions or those stupid tabs) with the procedure fired IN in appropriate templ;ate/document.

Template_A fires its own procedures.

Template_B fires its own procedures.

"When clicking tab button launching sub in t1, the VBA in that sub should launch sub in t2."

1. why not simply have a separate tab button produced by t2 and get it to fire a proecure from t2. WHY does a tab fromt1 have to fire from t2.

2. other than that, write the code for the t1 proecure to fire from t2.

"I'm not looking for a way to call template.dotx.projectname.modulename.subname or whatever.
I'm trying to call activedocument.projectname.modulename.subname"

Acvtually, no, you ARE in fact looking for a way to fire template.dotx.projectname. It is just a differnt dotx from t1.

"I'm trying to call activedocument.projectname.modulename.subname"" No, you ARE calling the activedocment.template.

But again, why not have the docuemnt template (NOT the global template loaded on startup) have its own tab firing mechanism?

Gerry
 
The reason I want this is actually because I can't get the Template_1 tab group and buttons to share tab with Template_2's.

I want a tab named Templates, in this, there is supposed to be a group with buttons loaded with XML from Template_1. Whenever a new document from Template_2 is created, extra buttons in the same tab is supposed to be shown.

However, when I try this, Word shows two tabs with same label even though I give them same id. Do you know how to make a single tab with groups/buttons from two templates?

That would solve all my problems, I believe!
 
I can't get the Template_1 tab group and buttons to share tab with Template_2's."

and...

" Do you know how to make a single tab with groups/buttons from two templates?"

No. It seems like a bad idea to me. The potential for error (not counting the infamous "ambigous" naming")seems huge.

Tabs, (menu items, shortcut jeys) all are pointers. Pointers point to single things. True, clever coding can make a call to a single procedure perform multiple actions, but the orgiinal pointer points to a single procedure.

On the other hand you CAN make multiple (different) pointer objects like tabs. menu items, shortcut keyboards point to the SAME procedure, in a global template.

Gerry
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top