#61
|
||||
|
||||
The basic code in in the zipped document attached to post #2. Open that document and press Alt-F11 to open the VBA Editor and access the code. Variations on the code have been discussed in numerous subsequent posts.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#62
|
|||
|
|||
Getting the macro to work
Hi Macropod
I am having difficulty to get your macro to work in my document. (I have never used macros before) I have been creating a word template. I copied across - Client and client details. I dont know how to copy and paste the macro across so it will work in my template. Also, does my template have to be saved as a word enabled template for it to work? Thank you |
#63
|
||||
|
||||
Without seeing your template, its impossible to diagnose the issue. Can you attach it to a post (delete anything sensitive)? You do this via the paperclip symbol on the 'Go Advanced' tab at the bottom of this screen.
And yes, for the template to be able to use a macro you'd have to save it as a macro-enabled template.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#64
|
|||
|
|||
Thanks for the quick response.
I dont think it is an issue but more i dont know how to copy a macro from your document into mine |
#65
|
||||
|
||||
Open the template, then the VBE (Alt-F11) and select the template's 'This Document' code module. Copy the code from the relevant post, then paste it into the template's 'This Document' code module. Exit the VBE (Alt-F11) and save the template as a macro-enabled template.
Done.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#66
|
|||
|
|||
Hi Paul, I am new to macros as well, and am looking for a solution to my problem without avail. I tried your zipped file, and understood how it work, but I need something more complex.
My document has a drop down list called 'Test Code.' Drop down options are 1,2,3...10 I want to make it such that whichever option is chosen, fields across the document are automatically filled in based on the option. For illustration, these fields are 'Test Objective', 'Test Conditions', etc. which are not successive fields, but are in different places. How do I implement this? Thanks |
#67
|
||||
|
||||
See post #33: https://www.msofficeforums.com/word-...html#post90264
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#68
|
|||
|
|||
Hey Paul,
I looked back to #9 and #19, and didn't quite understand what you were trying to say. I tried messing around with the code based on what I thought was trying to be said, but failed to implement it without getting error codes every time. I have attached my template. Best, Vik |
#69
|
||||
|
||||
Since a docx file can't contain any macros and neither your post nor your document says what you're trying to achieve, I'm not in a position to advise.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#70
|
|||
|
|||
Sorry for the confusion. I messed up when removing the sensitive details and uploading. Here, I have attached it again.
What I'm trying to do is that when the Test Number is selected, I want the Description, Reason, and Objective to be filled in. I have filled these in to the values of the drop down list using '|', but I'm not able to have it print separately in different boxes. Thanks |
#71
|
||||
|
||||
See attached.
Note: Unless you want spaces either side of your Description, Reason, and Objective outputs, you shouldn't have them in the TestNo control's values. A generic version of the code is: Code:
Private Sub Document_ContentControlOnExit(ByVal ContentControl As ContentControl, Cancel As Boolean) Application.ScreenUpdating = False Dim i As Long, StrDetails As String With ContentControl If .Title = "Client" Then For i = 1 To .DropdownListEntries.Count If .DropdownListEntries(i).Text = .Range.Text Then StrDetails = .DropdownListEntries(i).Value Exit For End If Next If StrDetails = "" Then StrDetails = "||" With ActiveDocument.SelectContentControlsByTitle("Output1")(1) .LockContents = False .Range.Text = Split(StrDetails, "|")(0) .LockContents = True End With With ActiveDocument.SelectContentControlsByTitle("Output2")(1) .LockContents = False .Range.Text = Split(StrDetails, "|")(1) .LockContents = True End With With ActiveDocument.SelectContentControlsByTitle("Output3")(1) .LockContents = False .Range.Text = Split(StrDetails, "|")(2) .LockContents = True End With End If End With Application.ScreenUpdating = True End Sub
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#72
|
|||
|
|||
Thanks a lot for your help!
The spaces on the sides were just a holdover from the description I had previously, thanks for pointing it out. |
#73
|
|||
|
|||
Ongoing work in same document
I'm attaching the same document that I successfully got working earlier in this thread. When I recently added three names to my dropdown, the macro that updates names and phone numbers stopped working for my coworkers, but not for me! Not sure what's different on my machine vs. theirs. Thoughts?
Seth |
#74
|
||||
|
||||
The ContentControlOnExit macro is missing from your document. If the updates are working correctly on your system without it, that suggests you've added the ContentControlOnExit macro to the document's template on your system instead of to the document itself.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#75
|
|||
|
|||
Yep - not sure how that happened but it's fixed and working now! Thank you!
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Delete Multiple Entries | dudeabides | Office | 1 | 07-04-2011 02:49 AM |
Multiple task lists and multiple calendars | kballing | Outlook | 0 | 01-18-2011 10:23 AM |
Creating Multiple Contact Lists | meltee78 | Outlook | 1 | 01-03-2011 09:45 PM |
multiple calendar entries across a group | halfhearted | Outlook | 0 | 10-11-2009 12:13 PM |
Word Forms : Dropdown lists | wferaera45 | Word | 0 | 04-06-2006 03:02 AM |