Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #31  
Old 12-14-2016, 09:48 PM
macropod's Avatar
macropod macropod is offline Expanding tables with calculating form fields? Windows 7 64bit Expanding tables with calculating form fields? Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Quote:
Originally Posted by Father View Post
So Word doesn't have an option like Acrobat to put a "CLEAR FORM" button?


Not a huge... It's simple enough to do like you said.
No, though one could do that quite easily with a few lines of VBA:
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]
Reply With Quote
  #32  
Old 12-15-2016, 03:08 PM
Father Father is offline Expanding tables with calculating form fields? Windows 7 32bit Expanding tables with calculating form fields? Office 2013
Novice
Expanding tables with calculating form fields?
 
Join Date: Nov 2016
Posts: 29
Father is on a distinguished road
Default

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.

Quote:
Originally Posted by macropod View Post
No, though one could do that quite easily with a few lines of VBA:
What is the trigger for that? Does it clear it when you open the form?
Reply With Quote
  #33  
Old 12-15-2016, 03:59 PM
macropod's Avatar
macropod macropod is offline Expanding tables with calculating form fields? Windows 7 64bit Expanding tables with calculating form fields? Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

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]
Reply With Quote
  #34  
Old 12-15-2016, 04:09 PM
macropod's Avatar
macropod macropod is offline Expanding tables with calculating form fields? Windows 7 64bit Expanding tables with calculating form fields? Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Quote:
Originally Posted by Father View Post
What is the trigger for that? Does it clear it when you open the form?
The trigger is the user choosing to clear the form by running the macro (e.g. via a keyboard shortcut that you might assign). I doubt you'd want it to run every time you open the document...

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]
Reply With Quote
  #35  
Old 12-16-2016, 04:24 PM
Father Father is offline Expanding tables with calculating form fields? Windows 7 32bit Expanding tables with calculating form fields? Office 2013
Novice
Expanding tables with calculating form fields?
 
Join Date: Nov 2016
Posts: 29
Father is on a distinguished road
Default

Awesome. Thanks again. You've been an amazing help with this.
I'll run it through some trials and see how it works out.
Reply With Quote
  #36  
Old 12-16-2016, 09:38 PM
Father Father is offline Expanding tables with calculating form fields? Windows 7 32bit Expanding tables with calculating form fields? Office 2013
Novice
Expanding tables with calculating form fields?
 
Join Date: Nov 2016
Posts: 29
Father is on a distinguished road
Default

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?
Reply With Quote
  #37  
Old 12-16-2016, 10:33 PM
macropod's Avatar
macropod macropod is offline Expanding tables with calculating form fields? Windows 7 64bit Expanding tables with calculating form fields? Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

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]
Reply With Quote
  #38  
Old 12-20-2016, 04:15 PM
Father Father is offline Expanding tables with calculating form fields? Windows 7 32bit Expanding tables with calculating form fields? Office 2013
Novice
Expanding tables with calculating form fields?
 
Join Date: Nov 2016
Posts: 29
Father is on a distinguished road
Default

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.
Reply With Quote
  #39  
Old 12-20-2016, 10:23 PM
macropod's Avatar
macropod macropod is offline Expanding tables with calculating form fields? Windows 7 64bit Expanding tables with calculating form fields? Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

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
Attached Files
File Type: docm EXPLOSIVE OPERATIONS DEPARTMENT.docm (48.3 KB, 14 views)
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #40  
Old 12-21-2016, 12:06 PM
Father Father is offline Expanding tables with calculating form fields? Windows 7 32bit Expanding tables with calculating form fields? Office 2013
Novice
Expanding tables with calculating form fields?
 
Join Date: Nov 2016
Posts: 29
Father is on a distinguished road
Default

Quote:
Originally Posted by macropod View Post
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.

I'd attach an update with Table 9b now incorporated, but the forum software isn't cooperating right now...
Is lRow and lTbl the "address" for that specific table or any table?

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?
Reply With Quote
  #41  
Old 12-21-2016, 02:08 PM
macropod's Avatar
macropod macropod is offline Expanding tables with calculating form fields? Windows 7 64bit Expanding tables with calculating form fields? Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

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]
Reply With Quote
  #42  
Old 12-22-2016, 12:44 PM
Father Father is offline Expanding tables with calculating form fields? Windows 7 32bit Expanding tables with calculating form fields? Office 2013
Novice
Expanding tables with calculating form fields?
 
Join Date: Nov 2016
Posts: 29
Father is on a distinguished road
Default

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?
Reply With Quote
  #43  
Old 12-22-2016, 01:27 PM
macropod's Avatar
macropod macropod is offline Expanding tables with calculating form fields? Windows 7 64bit Expanding tables with calculating form fields? Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

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]
Reply With Quote
  #44  
Old 12-22-2016, 03:36 PM
Father Father is offline Expanding tables with calculating form fields? Windows 7 32bit Expanding tables with calculating form fields? Office 2013
Novice
Expanding tables with calculating form fields?
 
Join Date: Nov 2016
Posts: 29
Father is on a distinguished road
Default

Quote:
Originally Posted by macropod View Post
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.
Scratch that. I figured out an alternative. I have checklists with YES, NO, N/A. I made it so that when a checkbox is true it'll automatically fill the checklists' N/A boxes.
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.
Reply With Quote
  #45  
Old 12-22-2016, 04:00 PM
macropod's Avatar
macropod macropod is offline Expanding tables with calculating form fields? Windows 7 64bit Expanding tables with calculating form fields? Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

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]
Reply With Quote
Reply

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
Expanding tables with calculating form fields? 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

Other Forums: Access Forums

All times are GMT -7. The time now is 01:40 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft