View Single Post
 
Old 08-13-2014, 07:19 AM
macropod's Avatar
macropod macropod is offline Windows 7 32bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,467
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

There are some serious issues with your code snippet:
1. unless the whole cell range is bold, your code won't recognise it;
2. it unnecessarily processes every cell;
3. by referencing wdCell.Next.Range you're liable to produce an error when wdCell inevitably ends up as the last cell in the table; and
4. there is no indication of any xml file existing for the output.

Without knowing more about the table structure, there's not much more help I can give on that front. That said, applying the tags really doesn't require testing the contents of each & every cell. It can be done far more efficiently via Find/Replace. For example:
Code:
Sub Demo()
Application.ScreenUpdating = False
With ActiveDocument.Range
  With .Find
    .ClearFormatting
    .Replacement.ClearFormatting
    .Text = ""
    .Replacement.Text = ""
    .Format = True
    .Font.Bold = True
    .Forward = True
    .Wrap = wdFindStop
    .Execute
  End With
  Do While .Find.Found
    .Text = "<strong>" & .Text & "</strong>"
    .Font.Bold = False
    .Collapse wdCollapseEnd
    .Find.Execute
  Loop
End With
With ActiveDocument.Range
  With .Find
    .ClearFormatting
    .Replacement.ClearFormatting
    .Text = ""
    .Replacement.Text = ""
    .Format = True
    .Font.Italic = True
    .Forward = True
    .Wrap = wdFindStop
    .Execute
  End With
  Do While .Find.Found
    .Text = "<emphasis>" & .Text & "</emphasis>"
    .Font.Italic = False
    .Collapse wdCollapseEnd
    .Find.Execute
  Loop
End With
Application.ScreenUpdating = True
End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote