Replace word in html code string

Hi all

I want to replace center to left in a html code string and test StringReplace from this forum.
This is working correct in the ScriptEditor but if I want to run the script from VBA with the AppleScriptTask function it is not working.

This is working in the Editor and HTMLMessage is the string I read from the htm file with this

theFile is the path to the htm file

open for access theFile
set HTMLMessage to (read theFile)
close access theFile

set HTMLMessage2 to stringReplace(HTMLMessage, “align=center”, “align=left”)

[AppleScript]
on stringReplace(haystack, needle, replace)
–DJ Bazzie Wazzie
tell AppleScript
set oldTIDs to text item delimiters
set text item delimiters to needle
set lst to text items of haystack
set text item delimiters to replace
set str to lst as string
set text item delimiters to oldTIDs
end tell
return str
end stringReplace



Is there another way that I can try to see if applescripttask VBA function can work with it.

Thanks for any help

Ron

I choose to do the replace in VBA code and then only read the content in AppleScript.

Thanks