![]() |
|
#3
|
||||
|
||||
|
Notwithstanding that your 'master' document should be a template from which new documents are created rather than saved with a new name, you need to run your code with a batch process that opens all the appropriate documents and runs your code. You should also introduce some error handling to at least ensure that there are four tables or more in the documents. The following will work as a custom process with Document Batch Processes which will handle the files and folders.
Code:
Function ProcessTables(oDoc As Document) As Boolean
Dim oTbl As Table
Dim Row As Integer
Dim Col As Integer
Dim oCell As Range
Dim strCellText As String
On Error GoTo err_Handler
If oDoc.Tables.Count > 3 Then
Set oTbl = oDoc.Tables(3)
For Row = 1 To oTbl.Rows.Count
For Col = 1 To oTbl.Columns.Count
Set oCell = oTbl.Cell(Row, Col).Range
oCell.End = oCell.End - 1
strCellText = oCell.Text
Set oCell = oDoc.Tables(4).Cell(2, 3).Range
oCell.End = oCell.End - 1
If Trim(strCellText) = "X" Then
oCell.Text = "nailed it"
Exit For
Exit For
End If
Next Col
Next Row
ProcessTables = True
End If
lbl_Exit:
Exit Function
err_Handler:
ProcessTables = False
Resume lbl_Exit
End Function
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
| Tags |
| 2010, auto populate |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
Form auto fill based on a different field value.
|
stct | Word | 31 | 05-02-2024 04:48 PM |
| Auto fill drops down using VBA code based on selection | AgilityJS | Word VBA | 5 | 11-03-2015 07:50 PM |
| How to remove auto type entry | ep2002 | Excel | 19 | 11-06-2013 08:48 AM |
| Auto Entry Names etc Into Document | simonyglog | Word | 2 | 07-08-2010 10:22 AM |
Sequentail Number Each Row Based On Another Column Entry
|
KramerJ | Excel | 3 | 05-07-2009 11:35 PM |