frogman was telling us:
frogman nous racontait que :
> Where is the error?
> the error is marked ***''' '''***
[quoted text clipped - 8 lines]
> What is happening instead?
> it has to do with how i am tracking the tables
Does this last table have merged cells? If so, your code will not work.
There are problems with your table manipulation approach. If a table is
entirely comprised of cells with hidden text, you will remove the whole
table and therefore throw the counter out of sync and will get an error.
Also, you should review your code and remove all Selection objects and
replace then with Range object. This will make the code run faster and be
more reliable.
As an example, see my version of your "OnlyHiddenTextinRow" function:
Public Function OnlyHiddenTextinRow(oRow As Row) As Boolean
OnlyHiddenTextinRow = True
Dim oCell As Cell
For Each oCell In oRow.Cells
If oCell.Range.Font.Hidden <> True Then
OnlyHiddenTextinRow = False
Exit Function
End If
Next
End Function

Signature
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org
frogman - 21 Oct 2005 15:27 GMT
thank you
you helped me get there and i love the faster code
Sub SendToClient()
Application.ScreenUpdating = True
Application.ScreenUpdating = False
Application.ActiveDocument.Save
Application.ActiveWindow.ActivePane.View.ShowAll = True
Dim strNewName, strFileName, strLength, strFilePath, strLengthPath As
String
Dim intTableCount As Integer
Dim intTableIndex As Integer
Dim intTablesLeft As Integer
Dim intTableNotDeletedCount As Integer
Dim i As Integer
Dim j As Integer
Dim BMName As String
Dim BMCount As Integer
Dim CurrentBM As Bookmark
ReDim ary(ActiveDocument.Bookmarks.Count + 1) As Variant
intTableCount = ActiveDocument.Tables.Count
intTablesLeft = ActiveDocument.Tables.Count
strFileName = ActiveDocument.Name
strFilePath = ActiveDocument.FullName
strLengthPath = (Len(strFilePath))
strLength = (Len(strFileName))
strNewName = Left(strFilePath, strLengthPath - 4)
'if a row in a table is hidden delete it
For i = 1 To intTableCount
Dim oRow As Row
For Each oRow In ActiveDocument.Tables(i).Rows
If OnlyHiddenTextinRow(oRow) = True Then
oRow.Delete
End If
Next 'oRow
'if the is not deleted count it and make i increment to keep the
table collection pure
If intTableCount = ActiveDocument.Tables.Count Then
i = i + 1
intTableNotDeletedCount = intTableNotDeletedCount + 1
End If
'if the current count of the tables minus the tables not deleted is
greater than 0 then there are more tables to process
If ActiveDocument.Tables.Count - intTableNotDeletedCount > 0 Then
intTableCount = ActiveDocument.Tables.Count
i = i - 1
'if no more tables to process then clean the rest of the document
up.
ElseIf ActiveDocument.Tables.Count = intTableNotDeletedCount Then
ActiveWindow.View.ShowHiddenText = True
With Selection.Find
.ClearFormatting
.Font.Hidden = True
.Replacement.ClearFormatting
.Text = ""
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
'delete all the hidden text in the document
Selection.Find.Execute Replace:=wdReplaceAll
'save the new document with the ClientCopy tagged at the end
Application.ActiveDocument.SaveAs strNewName & "ClientCopy.doc",
wdFormatDocument
Application.ActiveWindow.ActivePane.View.ShowAll = False
Application.ScreenUpdating = True
'Get the number of bookmarks in the document
BMCount = ActiveDocument.Bookmarks.Count + 1
'Fill array with bookmark names
For j = 1 To BMCount
If j = ActiveDocument.Bookmarks.Count + 1 Then
ary(j) = ""
Else
Set CurrentBM = ActiveDocument.Bookmarks(j)
ary(j) = CurrentBM.Name
End If
Next j
'set j back to 1
j = 1
'delete the bookmark name until no more bookmark names exist
Do Until ary(j) = ""
BMName = ary(j)
ActiveDocument.Bookmarks(BMName).Delete
j = j + 1
Loop
Application.ActiveWindow.View.ShowHiddenText = False
Application.ScreenUpdating = True
'delete the toolbar
Application.CommandBars("Spec Tools").Delete
'deletes all code
Dim VBComp As VBIDE.VBComponent
Dim VBComps As VBIDE.VBComponents
Set VBComps = ActiveDocument.VBProject.VBComponents
For Each VBComp In VBComps
Select Case VBComp.Type
Case vbext_ct_StdModule, vbext_ct_MSForm,
vbext_ct_ClassModule
VBComps.Remove VBComp
Case Else
With VBComp.CodeModule
.DeleteLines 1, .CountOfLines
End With
End Select
Next VBComp
Application.ActiveDocument.Save
Exit Sub
End If
Next i
End Sub
'only delete the hidden rows
Public Function OnlyHiddenTextinRow(oRow As Row) As Boolean
OnlyHiddenTextinRow = True
Dim oCell As Cell
For Each oCell In oRow.Cells
If oCell.Range.Font.Hidden <> True Then
OnlyHiddenTextinRow = False
Exit Function
End If
Next
End Function