Jump to content

word: replace text produces style mismatch

Recommended Posts

I want to make a listed text into a single paragraph, but the replace of text fails with styles...
I have this code:

$oRangeFound = _Word_DocFind($oDoc, "Nutrition:" , 0, $oSearchRange, Default, Default, $wdParagraph)
$oRangeFound = _Word_DocRangeSet($oDoc, $oRangeFound, $WdWord, 1, $wdParagraph, 1) 
$oRangeFound = _Word_DocRangeSet($oDoc, $oRangeFound, Default, 1, $wdCharacter, -1) 

if $arrangeNutrition then
  local $oRange1 = $oDoc.Range($oRangeFound.Start, $oRangeFound.End)
  $oRange1 = _Word_DocFindEX($oDoc, Default, Default, $oRange1, Default, Default, Default, Default, Default, Default, "Heading 2")
  $oRange1 = _Word_DocRangeSet($oDoc, $oRange1, Default, Default, $wdParagraph, -1)
  $oRangeFound.End = $oRange1.Start

$resultTextNutrition = Stringreplace($oRangeFound.Text, @cr , " | ")

Consolewrite( "###" & $resultTextNutrition & @crlf)

$oRangeFound.Text = $resultTextNutrition & @crlf

From this:



 I want this (Nutrition style Normal with "Nutrition:" remains bold, and the rest of the text all in Normal without bold):


instead it becomes like ("Nutrition:" Heading 2, so it becomes part of the numbered list and New Title becomes 2 ...😞



Edited by frank10
Link to post
Share on other sites
  • frank10 changed the title to word: replace text produces style mismatch

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...