Find and Replace Script

  • Last Post 27 April 2020
Judgementus posted this 23 April 2020



I am turning customer emails into PDFs and storing them in the cloud.

I am turning the HTML email body into a PDF.  This is having some formatting issues with long email chains slowly turning into 1 inch wide.


I have found in the HTML body that the <Blockquote> is the blame, and when removed it resolves the formatting issue.


However I have no idea how to write a find and replace script.  I tried to modify the "RemoveCharFromVariable.vbs" already on the forum but with no success.


Can anyone help me?







Order By: Standard | Newest | Votes
luca.scarpati posted this 24 April 2020

Hi Vince,


you need to pass the value of your variable containing the html body to the script.

After that then to eliminate your specific "part" of varialble, you can simply find the best method to do it among these already existing examples, obviously you have to adapt them to your needs: 

  1. (in this example you must first find the part you need and after use an example for delete it)
  2. (simply replace, please check maybe using the log into script, the actual value of your html body)
  3. (similar to 2. but the part to be removed must be your case specification)


Have a nice day!


Best regards,


Judgementus posted this 24 April 2020

Thanks for the reply.


I've looked through the methods and taking parts that I think will work but script does not work

"2020-04-24 11:58:01:415 | Detailed | Script engine finished, result: -1983

2020-04-24 11:58:01:423 | Error | The server threw an exception. (Exception from HRESULT: 0x80010105 (RPC_E_SERVERFAULT))"


My script below:

'The user need to define the metadata which part of the new filename that need to be cleaned before using


'uncomment the line below for the test, the result shoul be abcdefghilmnopqrstuvz

'variable = "blockquote"


Dim Target

Target = ".*\$*(\<\/|\<(blockquote)"


'In this example the metadata is a OCRZONE variable

variable = Metadata.Values("EMAILHTMLBODY")


Dim arrLines

arrLines = Split(variable, "\r\n")


Dim matchedValue


'Then you can iterate it like this 

For Each strline in arrLines 

match = GetFirstMatch(Target, strline)

If match <> "" Then



End If



CALL Metadata.SetValues("PARTHTML",mystring)

I hoping to find the target row by row and then run the replace on the target.

I am self trained on VBS and would appreciate the help.

luca.scarpati posted this 24 April 2020

Hi Vince,


mmm your script is not clear, from what it seems you are passing to a VBS Replace function the Target variable which seems to be a RegEx ... therefore completely wrong. If I understand correctly what you are doing you need to pass the found variable "match" as parameter in the Replace function wink.

Your Scanshare process is normal to have that error "RPC_E_SERVERFAULT" because your Script crash, as always I suggest trying the script first to execute it without the "CALL" of our SDK but with some VBS MSGBOX so as to understand if it works apart from Scanshare .


Have a nice weekend!


Best regards,


Judgementus posted this 27 April 2020

Hi Luca,


Thanks for your reply.

I have spent several hours over the weekend trying to progress this, with no success.


Would it be possible to en-list your help with this script for a nominal fee?

luca.scarpati posted this 27 April 2020

Hi Vincent,


more than welcome but they are not forum topics because the case listed is specific to your problem and the solutions in general are already present in the links/info above.


Maybe, since you have already opened a similar ticket to our support, update the status of that ticket smile.


Best regards,