Question

I have the need to automate conversion of html files into MS Word files, and as part of it I want to remove all ocorances of style Normal (Web) and replace them with just Normal.

I'm using the following

$find = $word.Selection.Find
$find.Style = $word.ActiveDocument.Styles.Item("Normal (Web)")
$find.Forward = $True
$find.Format = $True
while ($word.Selection.Find.Execute())
{
    $word.Selection.Style = $word.ActiveDocument.Styles.Item("Normal")
    $null = $word.Selection.EndKey(5)
}

which works but is slow. Is there a faster way?

Was it helpful?

Solution

Found an approch which doesn't replace, but has the desired effect:

$style = $word.ActiveDocument.Styles.Item("Normal (Web)")
$style.Delete()
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top