Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 08-21-2018, 01:59 AM
brichigo brichigo is offline dropdown list to create tables Windows 7 64bit dropdown list to create tables Office 2007
Novice
dropdown list to create tables
 
Join Date: Aug 2018
Posts: 5
brichigo is on a distinguished road
Default dropdown list to create tables

Hi,

Is there a way to auto-create a table based on the selected drop down list in Word 2007?

i.e
Dropdown list


Yes -> If user selects yes, the a 2 column 2 rows table will be created.
No

Thanks!
Reply With Quote
  #2  
Old 08-21-2018, 02:48 AM
macropod's Avatar
macropod macropod is offline dropdown list to create tables Windows 7 64bit dropdown list to create tables Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Yes. What kind of drop down list? What kind of content will the table have and is it to be editable, or just displayed?
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 08-23-2018, 10:09 AM
brichigo brichigo is offline dropdown list to create tables Windows 7 64bit dropdown list to create tables Office 2007
Novice
dropdown list to create tables
 
Join Date: Aug 2018
Posts: 5
brichigo is on a distinguished road
Default

Hi Paul,

A dropdown list with value yes and no only.

If I select 'yes', then a table should appear (see attached image). It should be editable.

Thank you in advance!
Attached Images
File Type: png sample.png (1.5 KB, 48 views)
Reply With Quote
  #4  
Old 08-23-2018, 02:21 PM
macropod's Avatar
macropod macropod is offline dropdown list to create tables Windows 7 64bit dropdown list to create tables Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Quote:
Originally Posted by brichigo View Post
A dropdown list with value yes and no only.
That tells me what the options are, but not what kind of dropdown you're using, which could be any of a formfield, content control or ActiveX control.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #5  
Old 08-23-2018, 11:54 PM
brichigo brichigo is offline dropdown list to create tables Windows 7 64bit dropdown list to create tables Office 2007
Novice
dropdown list to create tables
 
Join Date: Aug 2018
Posts: 5
brichigo is on a distinguished road
Default

Quote:
Originally Posted by macropod View Post
That tells me what the options are, but not what kind of dropdown you're using, which could be any of a formfield, content control or ActiveX control.
It is content control dropdown but we can change it to any kind of dropdown as long as the desired table will appear when we select the 'Yes' option.
Reply With Quote
  #6  
Old 08-24-2018, 04:33 AM
macropod's Avatar
macropod macropod is offline dropdown list to create tables Windows 7 64bit dropdown list to create tables Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Try the attached. The document has a dropdown content control titled 'Demo' and a bookmark named 'Tbl' where the table might go. Pressing Alt-F11 will expose the VBA code that drives the process when the content control is exited.
Attached Files
File Type: docm Conditional Table Insertion Demo.docm (41.1 KB, 42 views)
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #7  
Old 08-30-2018, 03:04 AM
brichigo brichigo is offline dropdown list to create tables Windows 7 64bit dropdown list to create tables Office 2007
Novice
dropdown list to create tables
 
Join Date: Aug 2018
Posts: 5
brichigo is on a distinguished road
Default

Quote:
Originally Posted by macropod View Post
Try the attached. The document has a dropdown content control titled 'Demo' and a bookmark named 'Tbl' where the table might go. Pressing Alt-F11 will expose the VBA code that drives the process when the content control is exited.
Thank you so much!
Reply With Quote
  #8  
Old 09-04-2018, 12:04 AM
brichigo brichigo is offline dropdown list to create tables Windows 7 64bit dropdown list to create tables Office 2007
Novice
dropdown list to create tables
 
Join Date: Aug 2018
Posts: 5
brichigo is on a distinguished road
Default

Hi macropod, how can I insert a content control dropdown list below the "Account" text? I tried modifying the code but it always inserting the dropdown list outside the table.

Appreciate your help.
Reply With Quote
  #9  
Old 09-04-2018, 02:36 AM
macropod's Avatar
macropod macropod is offline dropdown list to create tables Windows 7 64bit dropdown list to create tables Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Try, for example:
Code:
Private Sub Document_ContentControlOnExit(ByVal CCtrl As ContentControl, Cancel As Boolean)
Dim Tbl As Table, Rng As Range
If CCtrl.Title <> "Demo" Then Exit Sub
Application.ScreenUpdating = False
Set Rng = ActiveDocument.Bookmarks("Tbl").Range
Select Case CCtrl.Range.Text
  Case "Yes"
    If Rng.Tables.Count > 0 Then Exit Sub
    Set Tbl = Rng.Tables.Add(Range:=Rng, NumRows:=1, NumColumns:=2)
    With Tbl
      .AllowAutoFit = False
      .Borders.Enable = True
      .Rows.Height = InchesToPoints(0.75)
      .Columns(1).Width = InchesToPoints(2.5)
      .Columns(2).Width = InchesToPoints(3)
      With .Cell(1, 1).Range
        .Text = "Account:" & vbCr & " "
        .ContentControls.Add Type:=wdContentControlText, Range:=.Paragraphs(2).Range.Characters.First
        .ContentControls(1).Range.Text = ""
        .Paragraphs(1).Range.Font.Bold = True
      End With
      With .Cell(1, 2).Range
        .Text = "Remarks:" & vbCr
        .Paragraphs(1).Range.Font.ColorIndex = wdTurquoise
      End With
    End With
  Case Else
    If Rng.Tables.Count > 0 Then Rng.Tables(1).Delete
End Select
Set Tbl = Nothing: Set Rng = Nothing
Application.ScreenUpdating = True
End Sub
Code in the attachment in post #6 updated.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Selection of a dropdown creates another dropdown wih the list krishnamurthy.ka2810 Word VBA 1 04-26-2018 11:44 PM
dropdown list to create tables Dropdown content control and tables hrzagi Word 1 12-17-2017 09:38 PM
dropdown list to create tables Change colours in different tables based on dropdown selections kevinbradley57 Word VBA 10 08-09-2017 03:54 PM
excel2016: can't create dropdown afik Excel 4 11-13-2016 01:38 PM
Help!! Dropdown List christo16 Word 1 06-29-2015 05:18 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 12:08 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft