How to preserve formatting in PowerPoint when replacing text with RegEx in VBA -
i using regex in vba replace text in powerpoint presentation, of original formatting altered after running script. specifically, bullet points , font colours.
here code using. how can alter in order preserve initial format?
sub use_regex2() dim regx object dim osld slide dim oshp shape dim strinput string dim b_found boolean dim irow integer dim icol integer 'move dollar sign end of numbers set regx = createobject("vbscript.regexp") regx .global = true .pattern = "([$])([0-9,.]*\d)" end each osld in activepresentation.slides each oshp in osld.shapes if oshp.hastable irow = 1 oshp.table.rows.count icol = 1 oshp.table.columns.count strinput = oshp.table.cell(irow, icol).shape.textframe.textrange.text b_found = regx.test(strinput) if b_found = true strinput = regx.replace(strinput, "$2 $1") oshp.table.cell(irow, icol).shape.textframe.textrange = strinput end if next icol next irow else if oshp.hastextframe if oshp.textframe.hastext strinput = oshp.textframe.textrange.text b_found = regx.test(strinput) if b_found = true strinput = regx.replace(strinput, "$2 $1") oshp.textframe.textrange = strinput end if end if end if end if next oshp next osld set regx = nothing end sub
any appreciated.
Comments
Post a Comment