#16
|
|||
|
|||
If I run the macro in the doc you sent me, it works fine. If I change the "BkMk" to anything else if gives me the "Bookmark:XXX not found", and does not insert a form field. What am I missing here? Thanks-
|
#17
|
||||
|
||||
Quote:
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#18
|
|||
|
|||
If I use it in the doc I'm working, and give it the bookmark of the drop-down menu, it erases the drop-down menu. If I give it the bookmark of any other form field in the doc, it erases and replaces that form field. So it is not giving an additional (new) form field. Thanks-
|
#19
|
||||
|
||||
Quote:
Quote:
Quote:
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#20
|
|||
|
|||
So, I'm really confused. When the drop-down menu is XX, I want the exit macro to create a new additional form field. Am I explaining correctly or not?
|
#21
|
||||
|
||||
Quote:
To determine where the dependent text formfield should go, a bookmark is needed. To that end, the document I provided has a bookmark named 'BkMk' at the destination. The macro likewise refers to that bookmark - not the dropdown's bookmark or any other formfield's bookmark. So, if you want to use the macro, you need to do likewise. Your bookmark name doesn't have to be 'BkMk' but, if you decide to use any other name, you must create the bookmark via Insert|Bookmark and edit the macro to refer to that name.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#22
|
|||
|
|||
OK, I finally got it. In the macro that inserts all of this stuff I have to create a bookmark for the new form field to go to. One more question and I'll stop bugging you-I would like to add default text to the new form field. How do I do that? You have been a great help, I have learned much. Too much to learn and so little time-Thanks
|
#23
|
||||
|
||||
Quote:
.FormFields.Add BmkRng, wdFieldFormTextInput the line: BmkRng.FormFields(1).TextInput.EditType wdRegularText, "My default text" where "My default text" is whatever you want for the default.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#24
|
|||
|
|||
The code works great. With this drop-down though I have three additional form fields that are conditional. I have tried working with the code you wrote and I get several error codes. Suggestions?
Do you have a book/books that I can read on the VBA subject? I have Mastering VBA and on other on and both of them do not define terms etc. that I can understand. Suggestions? Thanks- |
#25
|
||||
|
||||
Without seeing your code, plus the document you're trying to populate, you can't really expect anyone to give specific advice on what's wrong...
As for VBA programming books, I can't give specific recommendations - all my VBA skills are self-taught (mostly through helping people in forums such as this).
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#26
|
|||
|
|||
I can send you whatever you like.
|
#27
|
||||
|
||||
You could attach a document to a post, just as I did earlier in this thread, with some representative data (delete anything sensitive). You do this via the paperclip symbol on the 'Go Advanced' tab at the bottom of this screen.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#28
|
|||
|
|||
Here's the doc that has all of the text that the macro needs to produce. The years (1790-1940) are in a drop-down menu. The regular non-conditional form fields are the grey highlighted ones. There are 6 conditional form fields depending on the chosen year highlighted in yellow. There is one conditional drop-down menu (AorB).
What is done- The year drop-down. All of the text and conditional text. All of the bookmarks for the conditional form fields. What I need help on- The conditional form fields and the one conditional drop-down menu. Here is the drop-down exit macro which I am assuming where the additional code needs to go. I have tried to write it and failed miserably. Code:
Sub LockDD1() ' ' Exit macro ' ' Dim Prot As Variant, BmkRng As Range Const BmkNm As String = "Column" ' The bookmark name With ActiveDocument Prot = .ProtectionType If .ProtectionType <> wdNoProtection Then Prot = .ProtectionType .Unprotect Password:=Pwd End If If .Bookmarks.Exists(BmkNm) Then Set BmkRng = .Bookmarks(BmkNm).Range If .FormFields("DD1").Result = "1790" Then .FormFields.Add BmkRng, wdFieldFormTextInput BmkRng.FormFields(1).TextInput.EditType wdRegularText, "X," Else BmkRng.Delete End If .Bookmarks.Add BmkNm, BmkRng Else MsgBox "Bookmark: " & BmkNm & " not found." End If .Protect Type:=Prot, NoReset:=True End With Set BmkRng = Nothing Application.ScreenUpdating = False If ActiveWindow.View.Type = wdPageView Then ActiveWindow.ActivePane.View.Type = wdNormalView Else ActiveWindow.View.Type = wdPageView End If If ActiveWindow.ActivePane.View.Type = wdNormalView Then ActiveWindow.ActivePane.View.Type = wdPageView Else ActiveWindow.ActivePane.View.Type = wdNormalView End If End Sub |
#29
|
||||
|
||||
There's no fields of any kind in your document, so it's far from apparent what you're expecting. All I can see is plain text, some of which has grey highlighting and some of which has yellow highlighting.
Does you real document have all these paragraphs, or are the ones in your attachment simply the conditional variations on a single paragraph? You say you've done "The year drop-down. All of the text and conditional text. All of the bookmarks for the conditional form fields.", but none of these is present in your document. Nor is the code you're using to drive the process - the macro you posted certainly couldn't do any more than conditionally add a single formfield; it can't even do conditional text. As some of your paragraphs have additional strings, such as 'population schedule,' 'col.', 'line' 'dwelling' and 'family', I'm guessing they're your conditional text, but there's no indication of whether that's so.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#30
|
|||
|
|||
Here's the doc that the macros are in, there is no text in it because the macro creates all of the text that the other doc has-
|
Thread Tools | |
Display Modes | |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Multiple If statements, | Jamal NUMAN | Excel | 16 | 11-15-2022 11:59 PM |
Countif statements | Alaska1 | Excel | 5 | 02-05-2015 07:55 PM |
Using IF statements | stuwoolf | Excel | 2 | 01-10-2015 01:58 PM |
count if statements | Alaska1 | Excel | 1 | 05-14-2014 08:21 AM |
IF statements that shifts to right. | kent | Excel | 0 | 01-19-2006 02:23 PM |