#31
|
||||
|
||||
Quote:
Code:
Sub ClearForm() Application.ScreenUpdating = False ActiveDocument.Unprotect Password:=StrPwd ActiveDocument.Protect Type:=wdAllowOnlyFormFields, NoReset:=False, Password:=StrPwd Application.ScreenUpdating = True End Sub
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#32
|
|||
|
|||
Is there a way to assign which cell the mass amount goes into?
Right now it all goes to the same cell. If you add a row and select the other option, after the alert boxes have been filled in, the results for the mass go into the cell in the first row. What is the trigger for that? Does it clear it when you open the form? |
#33
|
||||
|
||||
Oops!
Change: Set Rng = .Tables(2).Cell(3, 2).Range to: Set Rng = .Tables(2).Cell(lRow, 2).Range
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#34
|
||||
|
||||
Quote:
If you're wanting pristine documents to work with, save one as a Word template (i.e. File>Save As>Save As Type:Word Macro Enabled Template (*.dotm)), then create new documents from that. See: https://support.office.com/en-us/art...2-1191BCE57DEB http://word.mvps.org/FAQs/Customizat...platePart1.htm
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#35
|
|||
|
|||
Awesome. Thanks again. You've been an amazing help with this.
I'll run it through some trials and see how it works out. |
#36
|
|||
|
|||
For the table and cell references how do you determine which cell to assign the code to?
With .Tables(lTbl).Cell(lRow, 1).Range.FormFields(1) Set Rng = .Tables(2).Cell(lRow, 2).Range .Tables(2) is the second table, correct? I'm using a cell ref macro that shows the output cell as column 2 row 3. The dropdown being in Column 1 row 3 I'm trying to use this macro for other items in the form. I'm guessing part of the problem is the cell references get all screwed up in merged cells. Does that make it impossible or just difficult? |
#37
|
||||
|
||||
To work with variable tables throughout, the code should always reference lTbl. During development, I only partially did that (and lRow). The problem code line, originally coded as:
Set Rng = .Tables(2).Cell(3, 2).Range should be coded as: Set Rng = .Tables(lTbl).Cell(lRow, 2).Range If you want to implement the same kind of row adding etc. in table 9b as I did for table 9a, you'll need to split the Nomenclature & lb data into separate columns, just as I did for table 9a. The problem isn't one of merged cells (you don't have any in those tables) but of simplifying the coding for the weights of the optional materiel. Indeed, my implementation of table 9a has merged cells where yours didn't (compare the first & second rows).
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#38
|
|||
|
|||
I was actually trying to identify the table/cell addresses to replicate the "other" condition in the drop-down that prompts an alert to enter what would be displayed in lieu of the choices in the menu.
I was trying to do it in block 4. to allow for the user to enter a location not in the list. When I copy the code for "other munitions" I couldn't figure out the table reference. For the code you did for "othermuntions" it was Set Rng = .Tables(2).Cell(lRow, 2).Range. I was able to do the next table by copying the code and naming it OtherDemo and changing .Tables(2) to .Tables(3). It worked. I'm not sure why it would be .Cell(Row,2) though... it's actually row 3. But when I do that for the table above munitions I'm assuming it's .Table(1) but I can't identify the row or cell for 4. LOCATIONS. |
#39
|
||||
|
||||
Unless you only ever want to modify row 3 in table 2, you really should be using
.Tables(lTbl).Cell(lRow, 2).Range That's because lTbl tells Word which table to modify and lRow tells Word which row in that table you're working with. If you're working on table 2, that's what lRow will contain and, if you're working on row 3, that's what lRow will contain. Note that it's lRow, not Row. Update attached with Table 9b now incorporated
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#40
|
|||
|
|||
Quote:
I have additional pages for this form that have separate tables. If I wanted to do this in those how do I identify that specific table? |
#41
|
||||
|
||||
lTbl is the index for whichever is the current table. So, yes, it's for any table. The GetTblRow macro tells Word which table and row you're working with. To ensure it's updated, simply call it from the relevant formfields. As shown in the latest attachment, the GetTblRow macro is called from the UXONomen# & UXONEW# formfields in table 9a and from the DEMONomen# & DEMONEW# formfields in table 9b. Those formfields call the GetTblRow macro to make sure the correct table & row are referenced for the 'on exit' work they have to do (i.e. adding new items / rows).
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#42
|
|||
|
|||
Is it possible to select something from a drop down that would create and populate additional rows and cells in a table that would either be hidden or not part of the table unless a specific condition was selected?
|
#43
|
||||
|
||||
Yes, it's possible but, unless you can hold this table in another document the macro always has access to, it's not a trivial undertaking; it would require writing code to create, populate and format the table from scratch, which could get quite involved if you're going to start adding formfields, etc.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#44
|
|||
|
|||
Quote:
This was one of the things I think I've seen in an Adobe PDF. I originally asked if it would be easier to use Acrobat to make this form. What I didn't realize is that for dynamic forms LiveCycle Designer is used. I know you can hide tables. |
#45
|
||||
|
||||
There are fairly simple ways of hiding tables in Word, but not if they have formfields. An alternative for a table that has formfields might be to have the table on display but the formfields within it locked so they can only be accessed if whatever condition you select from the dropdown has the appropriate answer selected.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
Tags |
calculating values, expanding table, form fields |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Macro to keep formatted form fields after mail merge or replace text with formatted form fields | jer85 | Word VBA | 2 | 04-05-2015 10:00 PM |
Tables with form fields | step10 | Word | 18 | 11-12-2013 02:27 PM |
Enable editing in expanding fields | marweste | Word | 11 | 10-21-2013 07:41 AM |
How to prevent Tables from expanding | HappyFingers | Word | 1 | 11-29-2010 01:54 PM |
Calculating Form Fields in Microsoft Word | wubba80 | Word | 1 | 06-25-2010 12:42 AM |