April 9, 2024
Contribute to the Microsoft 365 and Office forum!
Click here to learn more 💡
May 10, 2024
Word Forum Top Contributors:
Can drop down menus make different tables visible?
Report abuse
Thank you.
Reported content has been submitted
By dropdown menu, do you mean a content control dropdown box in the document? If so then proceed as follows.
1. Add the dropdown and define it's list members (here I've used Table A, Table B ...).
2. Create BuildingBlocks of each of the three tables. Use the AutoText gallery in the attached template. Name the building blocks "Table A, Table B, ...
3. Add the following code to the ThisDocument module of the template.
4. Add a bookmark "bmTable" where the table needs to appear.
Private Sub Document_ContentControlOnExit(ByVal CC As ContentControl, Cancel As Boolean)
Select Case CC.Title
Case "Table"
Select Case CC.Range.Text
Case "A"
UpdateBookmark "bmTable", "Table A"
Case "B"
UpdateBookmark "bmTable", "Table B"
Case "C"
UpdateBookmark "bmTable", "Table C"
End Select
End Select
End Sub
Sub UpdateBookmark(BmkNm As String, Optional strATName As String)
Dim BmkRng As Range
With ActiveDocument
If .Bookmarks.Exists(BmkNm) Then
Set BmkRng = .Bookmarks(BmkNm).Range
If strATName <> vbNullString Then
On Error Resume Next
BmkRng.Tables(1).Delete
On Error GoTo 0
Set BmkRng = ActiveDocument.AttachedTemplate.AutoTextEntries(strATName).Insert(Where:=BmkRng)
Else
BmkRng.Text = vbNullString
End If
.Bookmarks.Add BmkNm, BmkRng
End If
End With
Set BmkRng = Nothing
End Sub
When the user selects the table from the CC and exist, the appropriate table will appear at the bookmark.
***
Death smiles at us all, but all a man can do is smile back.
For more help with Word visit:
http://gregmaxey.com/word_tips.html
Report abuse
Thank you.
Reported content has been submitted
Was this reply helpful?
Sorry this didn't help.
Great! Thanks for your feedback.
How satisfied are you with this reply?
Thanks for your feedback, it helps us improve the site.
How satisfied are you with this reply?
Thanks for your feedback.
Thank you for the reply. I am doing my best to follow your instructions but I am brand new to programming MS word 2007. It sounds like what you described is exactly what I'm looking to do.
if possible, could you provide these directions in a "for dummies" kind of method.
I truly appreciate any help you can provide me.
Report abuse
Thank you.
Reported content has been submitted
Was this reply helpful?
Sorry this didn't help.
Great! Thanks for your feedback.
How satisfied are you with this reply?
Thanks for your feedback, it helps us improve the site.
How satisfied are you with this reply?
Thanks for your feedback.
I certainly don't mean to sound pompous or arrogant, but I really don't know what else I can do to make it clearer. Maybe this will help: See: http://gregmaxey.mvps.org/word_tip_pages/installing_employing_macros.html for instructions to employ the VBA code provided above.
***
Death smiles at us all, but all a man can do is smile back.
For more help with Word visit:
http://gregmaxey.com/word_tips.html
Report abuse
Thank you.
Reported content has been submitted
Was this reply helpful?
Sorry this didn't help.
Great! Thanks for your feedback.
How satisfied are you with this reply?
Thanks for your feedback, it helps us improve the site.
How satisfied are you with this reply?
Thanks for your feedback.
I was having trouble navigating throughout the modules. I think I almost have this set.
Right now when i select the drop down option I am getting the error
Run-time error '5941'"
the requested member of the collection does not exist.
When i click debug this is what is highlighted
Set BmkRng = ActiveDocument.AttachedTemplate.AutoTextEntries(strATName).Insert(Where:=BmkRng)
When i created the building blocks i selected
Gallery: autotext
Category: general
Save in: building blocks
Options: insert content only
I am thinking the building blocks are saved/attached incorrectly. When you mentioned attached template, is that a specific location I need to bring up?
I truly appreciate the help on this. Thanks Again!
Report abuse
Thank you.
Reported content has been submitted
Was this reply helpful?
Sorry this didn't help.
Great! Thanks for your feedback.
How satisfied are you with this reply?
Thanks for your feedback, it helps us improve the site.
How satisfied are you with this reply?
Thanks for your feedback.
AttachedTemplate is the template attached to the document. If your document began life as a new blank document, then that template is Normal. If it began life from some other template (e.g., My Letterhead Template, then that template is most likely the attached template.
When you create and save the buildingblock, save it in the name of the attached template, not BuildingBlocks.
***
Death smiles at us all, but all a man can do is smile back.
For more help with Word visit:
http://gregmaxey.com/word_tips.html
Report abuse
Thank you.
Reported content has been submitted
Was this reply helpful?
Sorry this didn't help.
Great! Thanks for your feedback.
How satisfied are you with this reply?
Thanks for your feedback, it helps us improve the site.
How satisfied are you with this reply?
Thanks for your feedback.
Thank you very much for your help on this. I was able to get this function to properly work. And you did make it pretty much idiot proof to do. Just took me some time to figure out how to navigate through Word and macros.
once again, thank you
Report abuse
Thank you.
Reported content has been submitted
Was this reply helpful?
Sorry this didn't help.
Great! Thanks for your feedback.
How satisfied are you with this reply?
Thanks for your feedback, it helps us improve the site.
How satisfied are you with this reply?
Thanks for your feedback.
You're welcome. I remember the time when I likewise struggled with macros. It is just hard to think like that now :-(
***
Death smiles at us all, but all a man can do is smile back.
For more help with Word visit:
http://gregmaxey.com/word_tips.html
Report abuse
Thank you.
Reported content has been submitted
Was this reply helpful?
Sorry this didn't help.
Great! Thanks for your feedback.
How satisfied are you with this reply?
Thanks for your feedback, it helps us improve the site.
How satisfied are you with this reply?
Thanks for your feedback.
I have one more question for you regarding these tables. While the function is working properly and loading the table. The Table formatting does not copy over.
When I go and manually insert the building block, the formatting is saved (bold, italics, font size, etc)
Why does this not copy over into the Table? is there something I need to do to get this to happen.
Once again, I am truly appreciative of the help you've given me on this
Report abuse
Thank you.
Reported content has been submitted
Was this reply helpful?
Sorry this didn't help.
Great! Thanks for your feedback.
How satisfied are you with this reply?
Thanks for your feedback, it helps us improve the site.
How satisfied are you with this reply?
Thanks for your feedback.
Question Info
Last updated April 2, 2024 Views 1,654 Applies to: