Search code examples
tinybutstrongopentbs

OpenTBS Replace Text


Is it possible to replace text without having to create a TAG?

I'm using a template to fill some data in a word document. One of the things I need to fill is the revision number, something like: "1º Revision" ([onshow.rev])

But the generated file can be re-submited several times, and I need to increment the revision for each time, but since the tag [onshow.rev] is gone from the first time, I can't do it anymore. Is it possible the replace just the text "1º Revision" with something line "2º Revision"?

thks


Solution

  • With TinyButStrong, You can directly modify the contents using $TBS->Source.
    But, with OpenTBS over TBS, you have to take care that only the current sub-file is actually accessible by $TBS->Source.

    For example, if you are working on an Ms Excel sheet, then you have to do a $TBS->PlugIn(OPENTBS_SELECT_SHEET, $Sheet) in order to select the sheet to modify.

    Here is how to replace your item in the template :

    $TBS->Source = str_replace("1º Revision", "2º Revision", $TBS->Source);