Monday, March 1, 2021

#1 2021-02-21 01:35:47 pm

rdb1968
Member
From:: Netherlands
Registered: 2012-02-15
Posts: 140
Website

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
[/applescript]

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

Thanks for any help

Ron

Last edited by rdb1968 (2021-02-21 01:37:40 pm)


Ron de Bruin Excel Automation
http://www.rondebruin.nl

Offline

 

#2 2021-02-22 01:28:11 pm

rdb1968
Member
From:: Netherlands
Registered: 2012-02-15
Posts: 140
Website

Re: Replace word in html code string

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

Thanks


Ron de Bruin Excel Automation
http://www.rondebruin.nl

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)