메인 컨텐츠로 가기

Word 문서에서 종속 드롭 다운 목록을 만드는 방법은 무엇입니까?


표시된 왼쪽 스크린샷과 같이 첫 번째 드롭다운의 옵션을 기반으로 두 번째 드롭다운 목록의 선택을 제한해야 합니다. 어떻게 할 수 있습니까? 이 문서에서는 Word 문서에서 종속 드롭다운 목록을 만드는 방법을 보여줍니다.

VBA 코드를 사용하여 Word에서 종속 드롭 다운 목록 만들기


VBA 코드를 사용하여 Word에서 종속 드롭 다운 목록 만들기

아래 VBA 코드는 Word 문서에서 종속 드롭다운 목록을 만드는 데 도움이 될 수 있습니다. 단계별 지침을 따르십시오.

1. 먼저 Word 문서에 두 개의 드롭 다운 목록을 삽입해야합니다. 딸깍 하는 소리 개발자 > 레거시 양식 > 드롭 다운 양식 필드. 스크린 샷보기 :

2. 첫 번째 드롭 다운 목록 (이 드롭 다운 목록이 상위 항목이어야 함)을 마우스 오른쪽 단추로 클릭하고 속성. 스크린 샷을 참조하십시오 :

3. 오프닝에서 드롭 다운 양식 필드 옵션 대화 상자에서 다음을 수행해야합니다.

3.1 카테고리를 드롭 다운 항목 상자를 클릭 한 다음 추가 버튼을 클릭하고 모든 범주가 ​​드롭 다운 목록 상자의 항목에 추가 될 때까지 작업을 반복합니다.

3.2 입력 드푸드즐겨찾기 상자.

3.3 OK 단추. 스크린 샷보기 :

4. 두 번째 드롭 다운 목록을 마우스 오른쪽 버튼으로 클릭하고 등록 그것을 여는 드롭 다운 양식 필드 옵션 대화 상자에서 다음을 입력합니다. dd카테고리즐겨찾기 상자를 클릭하고 OK 단추. 스크린 샷보기 :

5. 누르세요 다른 + F11 키를 눌러 응용 프로그램 용 Microsoft Visual Basic 창.

6. 에서 응용 프로그램 용 Microsoft Visual Basic 창을 클릭합니다 끼워 넣다 > 기준 치수, 그런 다음 VBA 코드 아래를 모듈 창에 복사하십시오.

VBA 코드 : Word에서 종속 드롭 다운 목록 만들기

Sub Populateddfood()
'Update by Extendoffice 2018/10/25
    Dim xDirection As FormField
    Dim xState As FormField
    On Error Resume Next
    Set xDirection = ActiveDocument.FormFields("ddfood")
    Set xState = ActiveDocument.FormFields("ddCategory")
    If ((xDirection Is Nothing) Or (xState Is Nothing)) Then Exit Sub
    With xState.DropDown.ListEntries
        .Clear
        Select Case xDirection.Result
            Case "Fruit"
                .Add "Apple"
                .Add "Banana"
                .Add "Peach"
                .Add "Lychee"
                .Add "Watermelon"
            Case "Vegetable"
                .Add "Cabbage"
                .Add "Onion"
            Case "Meat"
                .Add "Pork"
                .Add "Beef"
                .Add "Mutton"
        End Select
    End With
End Sub

배송 시 요청 사항:

1. 코드에서 필요에 따라 각 경우 아래 항목을 변경하십시오.

2. 드푸드dd카테고리 위의 두 항목에서 입력 한 북마크 옵션과 일치해야합니다. 드롭 다운 양식 필드 옵션 대화 상자.

7. 코드를 저장하고 문서로 돌아갑니다.

8. 첫 번째 드롭 다운 목록을 마우스 오른쪽 버튼으로 클릭하고 등록 를 열려면 드롭 다운 양식 필드 옵션 대화 상자. 대화 상자에서 위의 매크로 이름 (여기는 Popolateddfood)을 선택하십시오. 출구 드롭 다운 목록을 클릭 한 다음 OK 버튼을 클릭합니다.

9. 이제 개발자 > 편집 제한 아래 스크린 샷과 같이.

10. 에서 편집 제한 pane에서는 다음을 수행해야합니다.

10.1) 확인 이 유형의 편집 만 허용 문서에서 상자;

10.2) 선택 서식 채우기 드롭 다운 목록에서 옵션;

10.3) 클릭 예, 보호 시행 시작 단추;

10.4)에서 보호 시행 시작 대화 상자에서 암호를 입력하고 OK 단추. 스크린 샷보기 :

이제 종속 드롭다운 목록이 생성됩니다. 첫 번째 드롭다운 목록에서 과일을 선택하면 두 번째 드롭다운 목록에서 과일 카테고리만 선택할 수 있습니다.

최고의 사무 생산성 도구

Word 용 Kutools - Over로 단어 경험을 향상시키세요 100 놀라운 기능!

🤖 Kutools AI 도우미: AI로 글쓰기를 변화시키세요 - 콘텐츠 생성  /  텍스트 다시 쓰기  /  문서 요약  /  정보 문의 문서 기반, 모두 Word 내에서

📘 문서 숙달: 페이지 분할  /  문서 병합  /  다양한 형식으로 선택 항목 내보내기(PDF/TXT/DOC/HTML...)  /  PDF로 일괄 변환  /  페이지를 이미지로 내보내기  /  한 번에 여러 파일 인쇄...

컨텐츠 편집: 일괄 찾기 및 바꾸기 여러 파일에 걸쳐  /  모든 사진 크기 조정  /  테이블 행과 열 바꾸기  /  표를 텍스트로 변환...

🧹 손쉬운 청소: 쓸어버리다 추가 공간  /  섹션 나누기  /  모든 헤더  /  텍스트 상자  /  하이퍼 링크  / 더 많은 제거 도구를 보려면 다음 페이지를 방문하세요. 그룹 제거...

광고 삽입물: 삽입 천 단위 구분 기호  /  확인란  /  라디오 버튼  /  QR 코드  /  바코드  /  대각선 표  /  방정식 캡션  /  이미지 캡션  /  테이블 캡션  /  여러 장의 사진  / 더 자세히 알아보세요. 그룹 삽입...

🔍 정밀한 선택: 핀포인트 특정 페이지  /  테이블  /  모양  /  제목 단락  / 탐색 기능 향상 배우기 기능 선택...

스타 강화: 어떤 위치로든 빠르게 이동  /  반복되는 텍스트 자동 삽입  /  문서 창 간을 원활하게 전환합니다.  /  11 변환 도구...

👉 이러한 기능을 사용해 보고 싶으신가요? Word 용 Kutools는 다음을 제공합니다. 60 일 무료 사용, 제한 없음! 🚀
 
Comments (32)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
Hi there,

I have managed to follow the steps, thanks for your help.

I can't find my code when pressing Alt+F11 though? My drop downs are still there but I can't find the back coding?
This comment was minimized by the moderator on the site
Hi Crystal, thanks for the tutorial, it was useful and well written. Is it possible to add a third dropdown list with options that change depending on what is selected from the second dropdown list?
This comment was minimized by the moderator on the site
Hi Jack,

You can add a third drop-down list with options that change depending on what is selected from the second drop-down list. But you need to insert another "Drop-Down Form Field" and a new VBA code in advance.
1. Follow the steps from 1 to 4 in the post to create the first and second drop-down list and modify the properties.
2. Insert the third Drop-Down Form Field, double click to open it's Properties dialog box, enter a name in the Bookmark textbox (the same as the operation for the first and second drop-down lists) , in this case, I made up a random name called ddTaste, and then click OK.
https://www.extendoffice.com/images/stories/comments/comment-picture-zxm/word-drop-down1.png
3. Open the Microsoft Visual Basic for Applications window, enter the VBA code provided in the article into the Module1. Then insert a new Module (called Module2), copy and paste the following VBA code into this Module2.
VBA code: Use for the third dependent drop-down list

Sub PopulateddTaste()
Select Case ActiveDocument.FormFields("ddCategory").Result
Case "Apple"
With ActiveDocument.FormFields("ddTaste").DropDown.ListEntries
.Clear
.Add "AA"
.Add "BB"
End With
Case "Banana"
With ActiveDocument.FormFields("ddTaste").DropDown.ListEntries
.Clear
.Add "CC"
.Add "DD"
End With
Case "Peach"
With ActiveDocument.FormFields("ddTaste").DropDown.ListEntries
.Clear
.Add "EE"
.Add "FF"
End With
Case "Lychee"
With ActiveDocument.FormFields("ddTaste").DropDown.ListEntries
.Clear
.Add "GG"
.Add "HH"
End With
Case "Watermelon"
With ActiveDocument.FormFields("ddTaste").DropDown.ListEntries
.Clear
.Add "II"
.Add "JJ"
End With
Case "Cabbage"
With ActiveDocument.FormFields("ddTaste").DropDown.ListEntries
.Clear
.Add "LL"
.Add "MM"
End With
Case "Onion"
With ActiveDocument.FormFields("ddTaste").DropDown.ListEntries
.Clear
.Add "OO"
.Add "PP"
End With
Case "Pork"
With ActiveDocument.FormFields("ddTaste").DropDown.ListEntries
.Clear
.Add "QQ"
.Add "RR"
End With
Case "Beef"
With ActiveDocument.FormFields("ddTaste").DropDown.ListEntries
.Clear
.Add "SS"
.Add "TT"
End With
Case "Mutton"
With ActiveDocument.FormFields("ddTaste").DropDown.ListEntries
.Clear
.Add "UU"
.Add "VV"
End With
End Select
End Sub

Note: In the code, AA, BB, CC... are the items you want to show in the third drop-down list, based on what was selected from the second drop-down list. For example, when you select "Apple" in the second drop-down, the third drop-down list will display the items AA and BB. Please modify this items to meet your needs.
4. Save the code and go back to the document. Follow the step 8 in the article to specify the macro for the first drop-down.
5. Double click the second drop-down list, choose "PopulateddTaste" in the Exist drop-down list.
https://www.extendoffice.com/images/stories/comments/comment-picture-zxm/word-drop-down2.png
6. Then follow the step 8 to restrict editing in this document.
Now you have create a three level drop-down list.
https://www.extendoffice.com/images/stories/comments/comment-picture-zxm/word-drop-down3.gif
This comment was minimized by the moderator on the site
Thanks for getting back to me, your time and help is appreciated.
This comment was minimized by the moderator on the site
Hallo,

ist das ganze auch unter Outlook möglich. Leider bekomme ich das so nicht hin da die Eigenschaften des Dropdown Menüs ganz anders aussehen.

Ich wollte unter Aufgaben einen Reparaturauftrag erstellen wo man Gebäude,Bereich und dan Zimmernummer oder Bezeichnung auwählen kann.

Ist das möglich in Outlook/Aufgaben?



Danke
This comment was minimized by the moderator on the site
Hi,
You can create a drop-down list with custom field in Outlook Task window by following the steps in this article:
How To Add A Drop Down List With Custom Filed In Outlook Task Window?
https://www.extendoffice.com/documents/outlook/4453-outlook-custom-fields-tasks-drop-down.html
Or create a drop-down list in word then copy and paste it into the Task window as you need.
But if you want to create dependent drop-down lists in Outlook Task, no method has been found yet.
Sorry about that.
This comment was minimized by the moderator on the site
Hi, many thx for the detailed tutorial, but I have a question since the word template is for others' use. You mentioned protecting mode and a password is a must, this can do if I tell them the password, then there is a conflict: there are some other blanks which are needed to be filled in, this cannot be done only if the protecting mode is off. What should I do? Is there any method to meet both 2 needs?
This comment was minimized by the moderator on the site
Hi, thx for the detailed tutorial, but I have a question since the word template is for others' use, 
This comment was minimized by the moderator on the site
This was extremely helpful, thank you.
I have a question, is there a way to modify the code so that when I select a new item from the first drop-down list, the dependent one will clear up?
This comment was minimized by the moderator on the site
Sorry for the late reply, only stumbled upon this page today :-)
It already does that. The first statement inside the Select case ... End select construction clears the second list. If none of the criteria are met, nothing is added.
This comment was minimized by the moderator on the site
Hello, for some reason I cannot modify anything else in the word file if the drop down list is active. Is there a way to avoid that?

Thank you
This comment was minimized by the moderator on the site
I have the same issue has anyone been able to help on this one
This comment was minimized by the moderator on the site
سلام من همه مراحل رو رفتم ولی درآخر وقتی از لیست اول یه استان رو انتخاب می کنم تویه لیست دوم فقط شهر های اون استان رو نمیاره
چیکار باید بکنم؟
This comment was minimized by the moderator on the site
I am using this same code however the text that I replacing the ddcategory with has 100 plus words. Is there anyway to wrap the text to prevent it from going off of the page and disappearing?
This comment was minimized by the moderator on the site
I have the same problem!! :0
This comment was minimized by the moderator on the site
Thank you for this very useful resource.

Is it possible to repeat the same dependent drop down multiple times within a form?

I need the form filler to assign a category to each new row (but with the same options each time).I have successfully created the drop downs but when I restrict editing to test they seem to reset themselves as I work down the rows.

Thanks
Amy
There are no comments posted here yet
Load More
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations