Using Excel VBA to Find Empty Table Cells in Word Documents

johnodocs

New Member
Joined
Oct 31, 2015
Messages
23
Hi Guys

Let me first say I am not an advanced user with VBA but have always seemed to get along by trial and error but this week I have come undone and would be grateful for some help.

Here is the background. I have a spreadsheet with 1,500 rows that link to Parent Reports that out teachers' have done in Word Documents. Normally it is an administrators job to check all these and see if a teacher has left any cells blank in the tables within the document, meaning that it is incomplete - a horrible job but a necessary job.

I've been working with some code from here:Detect whether a table cell is empty

So far I have been able to get to the point when Excel opens the word document but it all unravels there. Also I get the error "The remote server machine does not exist or isn't available"

Any help would be greatly appreciated and of course let me know if you need more information


******

Sub ThemeBlankBox()

Dim Path As String
Dim objDoc As Word.Document
Dim objWord As Word.Application
Dim oCell As cell
Dim oRow As Row

Sheets("Data").Select
FinalRow = Range("A9999").End(xlUp).Row

For I = 2 To FinalRow

Path = Sheets("Data").Range("H" & I).Text


Set objWord = CreateObject("Word.Application")
Set objDoc = objWord.Documents.Open(Path)

objWord.Visible = True

With objDoc
For Each oRow In ActiveDocument.Tables(1).Rows ' this is where the error appears when running line by line (F8)
For Each oCell In oRow.Cells
If oCell.Range.Text = Chr(13) & Chr(7) Then
Range("K" & I).Value = "Empty Cells Present"

Else

Range("K" & I).Value = "Complete"
End If
Next oCell
Next oRow

End With

Next I

objWord.ActiveDocument.Close SaveChanges:=wdDoNotSaveChanges
objWord.Quit

End Sub

****
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
I didn't bother trying to find out what was causing the error(s) in the other code - I simply re-wrote it. As you can see, the structure I used is quite different.
 
Upvote 0

Forum statistics

Threads
1,214,998
Messages
6,122,643
Members
449,093
Latest member
Ahmad123098

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top