Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 08-03-2016, 08:13 PM
His Nerdship His Nerdship is offline Variable filler rows in an incomplete table Windows 7 32bit Variable filler rows in an incomplete table Office 2007
Novice
Variable filler rows in an incomplete table
 
Join Date: Aug 2016
Posts: 4
His Nerdship is on a distinguished road
Default Variable filler rows in an incomplete table

Good day,
I'm creating RTF templates for reports whose layout is very specific. If there is not enough data to fill a table such that it expands to the bottom of the page, I must instead insert rows of shading or diagonal lines to prevent anyone adding anything 'unofficial' into the blank rows.
For example in the attached JPG there are two data rows, but that leaves 12 empty rows that must be rendered 'out of bounds' by some form of shading. I manually added the rows of periods here, but I need to know if this can be automated such that it will fill up redundant rows to the end of the page.


Any ideas gratefully received. TIA.
Attached Images
File Type: jpg Table.jpg (76.5 KB, 19 views)
Reply With Quote
  #2  
Old 08-03-2016, 10:32 PM
gmayor's Avatar
gmayor gmayor is offline Variable filler rows in an incomplete table Windows 10 Variable filler rows in an incomplete table Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,101
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

Where does the data come from that fills the two used rows, or how is the number of used rows determined? If the data is being added by a macro process, as seems to be the case, then it would probably be better to begin with all the cells filled with characters and overwrite them as required with the process.

Ensuring that the random number of cells are not themselves overwritten by someone is a different issue and questions the reason for using an editable format in the first place. If you don't want users to edit the table manually then take that away from them by converting to (say) pdf or make the document read only.
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
  #3  
Old 08-03-2016, 11:48 PM
His Nerdship His Nerdship is offline Variable filler rows in an incomplete table Windows 7 32bit Variable filler rows in an incomplete table Office 2007
Novice
Variable filler rows in an incomplete table
 
Join Date: Aug 2016
Posts: 4
His Nerdship is on a distinguished road
Default

Thanks for replying, Graham.
The RTF file is a template for reports via Oracle Business Intelligence Publisher. One associates the template with an XML file, and then by putting placeholders in the RTF document and linking them to various elements in the XML document. BI then does a sort of mailmerge and creates a report by inserting the XML data where required.
As for preventing anyone overwriting a blank space, we are talking about a printed document, not the soft copy. The work is for agricultural export quarantine documents, the format of which is agreed and signed in blood by the exporting and importing governments. The worry is that, say, meat or grain that has not been inspected might be photocopied/whatever onto the list of items that have been cleared. I know it's pretty anal, but we're talking government bureaucrats here. Mine is not to reason why...
As for pre-filling the cells with 'shading', I tried that but as it fills rows with data it merely pushes the shaded rows down and onto the next page.
Is there a way I could pre-fill rows which can then be overwritten by data as needed, rather than expanding the table downwards?
Reply With Quote
  #4  
Old 08-04-2016, 05:13 AM
gmayor's Avatar
gmayor gmayor is offline Variable filler rows in an incomplete table Windows 10 Variable filler rows in an incomplete table Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,101
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

Without access to your process to change the part of the code that writes to the cell to replace the cell content rather than add to it, a pre-filled table is not going to be easy to achieve. The best I can manage for the moment is to fill the empty cells using a Word macro.
Code:
Sub FillTable()
Dim oTable As Table
Dim oCell As Cell
Dim oRng As Range
Dim i As Long
    If Not ActiveDocument.Tables.Count = 1 Then
        MsgBox "Invalid Document"
        GoTo lbl_Exit
    End If
    Set oTable = ActiveDocument.Tables(1)
    If Not oTable.Rows.Count = 13 Then   'the number of rows in the table
        MsgBox "Invalid Document - Row count = " & oTable.Rows.Count
        GoTo lbl_Exit
    End If
    For i = oTable.Range.Cells.Count To 1 Step -1
        Set oCell = oTable.Range.Cells(i)
        If Len(oCell.Range) = 2 Then
            Set oRng = oCell.Range
            oRng.End = oRng.End - 1
            oRng.Text = "....................."    'to fill the length of the cell
        End If
    Next i
lbl_Exit:
    Exit Sub
End Sub
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
  #5  
Old 08-04-2016, 07:00 PM
His Nerdship His Nerdship is offline Variable filler rows in an incomplete table Windows 7 32bit Variable filler rows in an incomplete table Office 2007
Novice
Variable filler rows in an incomplete table
 
Join Date: Aug 2016
Posts: 4
His Nerdship is on a distinguished road
Default

Thanks again Graham,
I will try it out now. I was hoping to avoid VBA, as we have several hundred of these templates and the guys who will be building them are business, not tech-heads. However from what you say, and I agree, there is no other way.
The poor guys will just have to become techies!
Reply With Quote
  #6  
Old 08-05-2016, 05:13 AM
gmayor's Avatar
gmayor gmayor is offline Variable filler rows in an incomplete table Windows 10 Variable filler rows in an incomplete table Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,101
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

It would help if you offered the users an add-in template containing the code - see attached.
This code is slower than the previous code, but it will put the correct number of periods in the cells no matter the size of the cell.
Attached Files
File Type: dotm FillTable.dotm (103.9 KB, 14 views)
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
  #7  
Old 08-07-2016, 04:21 PM
His Nerdship His Nerdship is offline Variable filler rows in an incomplete table Windows 7 32bit Variable filler rows in an incomplete table Office 2007
Novice
Variable filler rows in an incomplete table
 
Join Date: Aug 2016
Posts: 4
His Nerdship is on a distinguished road
Default

Cheers Graham, this is enough for me to work on.
I will hassle you again if I have any problems!
Thanks for your help and time.
Sholto
Reply With Quote
Reply

Tags
shading, table, variable

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Variable filler rows in an incomplete table Would like a macro to copy a cell down a variable number of rows Rod_Bowyer Excel Programming 6 03-25-2016 08:18 PM
Variable filler rows in an incomplete table Mail merge at large table with variable number of rows blar Mail Merge 1 10-19-2015 03:04 PM
Variable filler rows in an incomplete table Incomplete Table of Contents (Mac Office 2011) lead48 Word 2 05-31-2015 06:28 AM
Creating a table for a variable number of rows OllieOnline Mail Merge 1 03-27-2013 02:48 PM
Using macro to add variable number of rows to a protected word table Julia Word Tables 1 01-09-2013 06:04 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 09: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