![]() |
#1
|
|||
|
|||
![]()
Dear All Colleagues,
I need help about Word VBA. I have word document and need to add combo boxes containing five list items i.e. Excellent, Very Good, Good, Below Average, Poor. When I select the list item the following output is desired: Excellent; 1 ( Font color Green) Very Good; 2 (Color Green) Good; 3 (Color Orange) Below Average; 4 (Color Red) Poor; 5 (Color Red) I need this corresponding word on the same page when selected any item in combo box. Here is the screenshot of the same: http://prntscr.com/9wtr5s There are 11 sections which will contain same combo boxes and their output will be screened on summary page. The view of the summary page is as follows: http://prntscr.com/9wtlfr Score achieved will be added on summary sheet after selecting combo box item of each section page. I hope you understand this requirements. Please help |
#2
|
|||
|
|||
![]()
First of all why would you want a combobox, if your choices are fixed as described? Seems you would want a dropdown list.
I would use a dropdown list content control and then use the ContentControl_OnExit event in the ThisDocument module to evaluate the selection made and populate the data to other places. You state you need "help." What have you done for yourself? Here is a start: Code:
Private Sub Document_ContentControlOnExit(ByVal ContentControl As ContentControl, Cancel As Boolean) Select Case ContentControl.Title Case Is = "Section 1 Score" 'Write some text here 'Write this score there Case Is = "Section 2 Score" 'etc. End Select lbl_Exit: Exit Sub End Sub |
#3
|
||||
|
||||
![]()
fairchance: did you bother doing a search? This kind of problem has been addressed numerous times before...
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#4
|
|||
|
|||
![]()
Thank you sir for reply Sir. Here is my file please make this code here:
https://www.dropbox.com/s/0joqy9pr4s...late.docx?dl=0 Moreover, i have select combo box as the reader will read each section and put his remarks as Excellent etc. That will converted into numeric scores. I have give some detail on page no. 16-17. If you have another idea for this kindly share with me. Kind Regards |
#5
|
||||
|
||||
![]()
fairchance: This forum is not a free coding service. When I look at your posting history, one thing is clear: you expect others to do all the work for you. That is not fair!!! We are more than willing to help when you get into difficulty, but you should also invest some effort of your own.
As I said in my previous reply, a search of the forum will reveal numerous solutions for tasks such as yours. Make use of them.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#6
|
|||
|
|||
![]()
Sir,
Can you please refer the to the previous post link which is more close to my my post. Regards |
#7
|
|||
|
|||
![]()
Sir, I am waiting for your reply. Please guide me as early as possible.
|
#8
|
||||
|
||||
![]()
As I have already said, this forum is not a free coding service. Furthermore, a simple search of these forums will return examples of documents coded to do essentially what you are asking for. See, for example: https://www.msofficeforums.com/word-...selection.html
I do not see from your posts to date or from your attachment that you have made any effort to implement the code examples that are already available. When you're ready to give evidence that you have at least tried to do something meaningful and you need help with a particular aspect of the code, post back with your code and the specific details of what aspects of it you need help with.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#9
|
|||
|
|||
![]()
Dear Sir,
Hi I have done my work and color change is not my requirements now. My template is fine for Microsoft Office for Windows version. I need to convert this template for Microsoft Office 2006 for Mac as I have no idea about it. I hope you will definitely help me. Here is my file. https://www.dropbox.com/s/ns4wnwn24q...2%29.docm?dl=0 Kind Regards Fairchance |
#10
|
||||
|
||||
![]() Quote:
Regardless of which Mac version you mean, you will have to completely redo your form and its VBA code as Content Controls do not work on Mac versions 2004, 2008 & 2011 (Active-X controls do not work on any Mac version). You will need to use formfields instead. Do note, too, that Word 2008 does not support macros.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#11
|
|||
|
|||
![]()
Yes Sir, you are right it is Microsoft Office 2016 for Mac. Secondly, Can you give me some initial start with Form Field Drop Down coding. Simply, If i place this field on word file in Windows Version of this office then drop down box is not working.
Thank you for guidance. |
#12
|
||||
|
||||
![]()
For dropdown formfields, you could employ a macro like:
Code:
Sub ColorDropDown() Dim sText As String, oFld As FormField Const Pwd As String = "" With ActiveDocument Set oFld = Selection.FormFields(1) sText = oFld.Result If .ProtectionType <> wdNoProtection Then .Unprotect Password:=Pwd With oFld.Range Select Case sText Case Is = "Bad" .Font.Color = wdColorRed Case Is = "Poor" .Font.Color = wdColorOrange Case Is = "Fair" .Font.Color = wdColorYellow Case Is = "Good" .Font.Color = wdColorGreen Case Is = "Excellent" .Font.Color = wdColorBlue Case Is = "Outstanging" .Font.Color = wdColorIndigo Case Else .Font.Color = wdColorBlack End Select End With .Protect Type:=wdAllowOnlyFormFields, NoReset:=True, Password:=Pwd End With End Sub
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#13
|
|||
|
|||
![]()
Thank You Sir for guidance. Actually, the color change on selection of particular drop down item is not required now as I have told you earlier. I need the score change with drop down selection item.
I have tried to implement legacy form control in my template but the score is not being change on selecting the drop down item. Kindly guide me about the following: 1. Whether the below template will be workable on Mac Machine? 2. How the score will be change after changing of every drop down item. https://www.dropbox.com/s/f0y0xh8dtg..._Mac.docm?dl=0 Kind Regards Shehbaz H. |
#14
|
||||
|
||||
![]() Quote:
Quote:
Quote:
https://www.msofficeforums.com/word/...html#post30197 https://www.msofficeforums.com/word/...html#post88302 https://www.msofficeforums.com/word/...html#post74823
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#15
|
|||
|
|||
![]()
Dear Sir,
Thank you so much for guidance. I have implemented your logic and seeking your little advise. The field codes are updating when selecting next action dropdown otherwise these are not updating even if I click other part of document. Please check and rectify. Thank You Regards https://www.dropbox.com/s/wgn78647ou...2%29.docm?dl=0 |
![]() |
Thread Tools | |
Display Modes | |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
marksm33 | Word VBA | 3 | 01-15-2015 07:55 PM |
![]() |
alidaanish | Word | 1 | 01-10-2014 10:44 PM |
![]() |
BoringDavid | Word VBA | 12 | 12-12-2013 05:14 AM |
Display paragraph of text based on value selected in combo | WordWaza | Word | 0 | 08-09-2013 06:30 AM |
Bold list items in a combo box | DrewB | Word VBA | 0 | 07-17-2009 11:32 AM |