Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #3  
Old 04-17-2015, 04:49 AM
tejaspareek tejaspareek is offline Automatically adding new rows based on form field Windows 7 64bit Automatically adding new rows based on form field Office 2010 64bit
Novice
Automatically adding new rows based on form field
 
Join Date: Oct 2014
Posts: 13
tejaspareek is on a distinguished road
Default Thank you

Thank you Greg,

My 90% problem is solved.
However, when i tried to impliment the code in my form sheet, i am facing an issue. The installment number in the table remains 1 for all the installment. The table that you created changed the number for all the installment, however, the same is not working in the document. I made some changes in the code while using it in my form, did i make any mistake in entering the code?

Code:
Private Sub Document_ContentControlOnExit(ByVal ContentControl As ContentControl, Cancel As Boolean)
Dim lngCount As Long
Dim oTbl As Word.Table
Select Case ContentControl.Title
  Case "Installments"
    If ActiveDocument.ProtectionType <> wdNoProtection Then ActiveDocument.Unprotect
    Set oTbl = Bookmarks("Inst1").Range.Tables(1)
    For lngCount = oTbl.Rows.Count To 5 Step -1
      oTbl.Rows.Last.Delete
    Next lngCount
    For lngCount = 2 To CLng(ContentControl.Range.Text)
      oTbl.Rows.Last.Range.Copy
      oTbl.Rows.Last.Range.Paste
    Next lngCount
    For lngCount = 1 To CLng(ContentControl.Range.Text)
      If IsNumeric(oTbl.Rows(2).Cells(2).Range.ContentControls(1).Range.Text) Then
        oTbl.Rows(lngCount + 3).Cells(2).Range.ContentControls(1).Range.Text = _
          oTbl.Rows(2).Cells(2).Range.ContentControls(1).Range.Text / CLng(ContentControl.Range.Text)
      Else
        oTbl.Rows(lngCount + 3).Cells(2).Range.ContentControls(1).Range.Text = "$0.00"
      End If
    Next lngCount
    oTbl.Range.Fields.Update
    oTbl.Rows(4).Cells(2).Range.ContentControls(1).Range.Select
    ActiveDocument.Protect wdAllowOnlyFormFields, True
End Select
End Sub
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Automatically adding new rows based on form field Form auto fill based on a different field value. stct Word 31 05-02-2024 04:48 PM
Automatically adding new rows based on form field VBA to automatically sort items based on Mail Merge field taylorblu Word VBA 3 09-08-2014 09:52 AM
MACRO - Insert row based on Form Field Criteria Elan05 Word VBA 5 04-16-2013 06:39 AM
Is there a way to do this? (automatically enter text based on form data) TIKKI555 Word 0 05-26-2010 09:21 AM
Form field to automatically be added to header? razberri Word VBA 3 02-22-2010 03:48 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 09:39 PM.


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