Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 08-10-2020, 01:17 PM
chriscla chriscla is offline date picker in dropdown list Windows 10 date picker in dropdown list Office 2013
Novice
date picker in dropdown list
 
Join Date: Mar 2020
Posts: 18
chriscla is on a distinguished road
Default date picker in dropdown list

Hi

I'm trying to have a date picker as one of the choices in a dropdown list, but since the items to choose from are only text, I'm stuck.
The situation is as follows:
I have a dropdown list with two choices: the check of the installation is done ('doorlopen' in the code below) or not done. When the check is not done, there is text: 'not done'. But when the check has been done, I would like to have again two choices: date unknown or date of check. This date of check should be entered by a date picker.



Is this possible or am I wishing for the impossible?

The code I'm using now is (thanks to GMayor):

Code:
Private Sub Document_ContentControlOnExit(ByVal ContentControl As ContentControl, Cancel As Boolean)
  Dim i As Long
  Dim oCC As ContentControl
      With ContentControl
          Select Case .Title
              Case Is = "doorlopenJN"
                  If .ShowingPlaceholderText = True Then
                      Set oCC = ActiveDocument.SelectContentControlsByTitle("doorlopenTekst").Item(1)
                      oCC.LockContentControl = True
                      oCC.Range.Text = ""
                  Else
                      For i = 1 To .DropdownListEntries.Count
                          If .DropdownListEntries(i).Text = .Range.Text Then
                              Select Case .DropdownListEntries(i).Text
                                  Case "doorlopen"
                                      AutoTextToCC "doorlopenTekst", ActiveDocument.AttachedTemplate, "DoorlopenJa"
                              End Select
                              Exit For
                          End If
                      Next
                  End If

        End Select
    End With
End Sub
(This is with an autotext to be inserted after the choice in the first combobox), maybe this would work also but I can't figure out how.

Thanks for any help.
Chris
Reply With Quote
  #2  
Old 08-10-2020, 02:59 PM
gmaxey gmaxey is offline date picker in dropdown list Windows 10 date picker in dropdown list Office 2016
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,422
gmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the rough
Default

It isn't going to work. You can't have a datepicker or an autotext entry as the a choice is a dropdownlist.
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
  #3  
Old 08-10-2020, 04:57 PM
Guessed's Avatar
Guessed Guessed is offline date picker in dropdown list Windows 10 date picker in dropdown list Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,932
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

What if the 'dropdown list' was actually an Building Block Gallery Content Control?

All the text and date picker CC options would need to be saved as building blocks.
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
  #4  
Old 08-11-2020, 11:31 AM
chriscla chriscla is offline date picker in dropdown list Windows 10 date picker in dropdown list Office 2013
Novice
date picker in dropdown list
 
Join Date: Mar 2020
Posts: 18
chriscla is on a distinguished road
Default solution

Thanks for the input. I solved it as Guessed suggested by using building blocks as a reply to the choice made in the dropdown list, where:
- when the check has been done: 'check done' in dropdown and date picker in building block 'DoorlopenJa'
- when the check has been done without knowing the date: 'check done, but date unknown' in dropdown, '. ' in building block 'DoorlopenNee'. I could do this because the dropdown is at the end of a sentence.
- when the check has not been done: 'check not done' in dropdown, '. ' in building block 'DoorlopenNee'.

This may not be the most attractive way to do it, but it does the job.

Code:
Private Sub Document_ContentControlOnExit(ByVal ContentControl As ContentControl, Cancel As Boolean)
Dim i As Long
Dim oCC As ContentControl
    With ContentControl
        Select Case .Title
Case Is = "doorlopenJN"
                If .ShowingPlaceholderText = True Then
                    Set oCC = ActiveDocument.SelectContentControlsByTitle("doorlopenTekst").Item(1)
                    oCC.LockContentControl = True
                    oCC.Range.Text = ""
                Else
                    For i = 1 To .DropdownListEntries.Count
                        If .DropdownListEntries(i).Text = .Range.Text Then
                            Select Case .DropdownListEntries(i).Text
                                Case "doorlopen "
                                    AutoTextToCC "doorlopenTekst", ActiveDocument.AttachedTemplate, "DoorlopenJa"
                                Case "doorlopen, datum niet gekend"
                                    AutoTextToCC "doorlopenTekst", ActiveDocument.AttachedTemplate, "DoorlopenNee"
                                Case "niet doorlopen"
                                    AutoTextToCC "doorlopenTekst", ActiveDocument.AttachedTemplate, "DoorlopenNee"
                            End Select
                            Exit For
                        End If
                    Next
                End If
        End Select
    End With
End Sub
Thanks again to Guessed and gmaxey to point me in the right direction.
Reply With Quote
  #5  
Old 08-11-2020, 04:52 PM
macropod's Avatar
macropod macropod is offline date picker in dropdown list Windows 7 64bit date picker in dropdown list Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
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

You could, of course, use something like:
Code:
Private Sub Document_ContentControlOnExit(ByVal CCtrl As ContentControl, Cancel As Boolean)
With CCtrl
  If .Title = "Dropdown1" Then
    If .Range.Text = "Date" Then
      .Type = wdContentControlDate
      .Range.Text = ""
      .Range.Select
    ElseIf .Range.Text = .PlaceholderText Then
      .Type = wdContentControlDropdownList
      .Range.Select
    End If
  End If
End With
End Sub
and have 'Date' as one of the dropdown choices.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
date picker in dropdown list Selecting a Date in Date Picker and Having it change dates throughout joshuaran Word VBA 2 03-14-2018 09:24 PM
date picker in dropdown list Date picker content control to always show current date. lucky16 Word VBA 2 07-01-2016 01:14 PM
dropdown lists and date picker added to word doc. greg__reynolds Word 3 05-19-2014 12:19 AM
Possible to link a date picker to another date picker? tubbz Word 0 05-07-2014 01:23 PM
Date picker trintukaz Excel 0 12-30-2011 12:42 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 01:27 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