AppleScript search / replace in Excel sheet text Document

I'm new on Applescript and I'm trying to create a script that can browse a document text (.html) and find and replace different phrases with a corresponding cell in an Excel document.

I'll put placeholders in the text to be replaced like B_1 (first value to replace), B_2 (second), B_3 etc...

They must be replaced in order using the cells B1-B9 in the Excel document. Phrases in the Excel document will be changed each time, so why it must be dynamic to capture them rather than a standard find & replace the script with static values.

I followed this thread that everything is logical:https://discussions.apple.com/thread/7008048?start=0 & tstart = 0

However, I continue to run into compile errors. Here is my current code:

tell application "Microsoft Excel" set colB_data to value of every cell of range "B1:B9" of worksheet 1 of document 1 end tell tell application "Sublime Text" tell text of "Users/maxquinn/Desktop/index.html" repeat with index from 1 to count colB_data replace ("B_" & index as text) using (item index of colB_data) options {starting at top:true, match words:true} end repeat end tell end tell 

The first half works fine, but the second half gives me error "Expected end of line but found identifier." and highlights the 'using' in the 'replace' command (line 8) .

Anyone know why this could be and is there any other glaring error in the script?

Thank you!

Max

Restructure your AppleScript in the Apple Script Editor (then do not peer in a continuous line of code) and then paste here using the Advanced Editor. Then select all the posted AppleScript and in the Style menu, choose paragraph. Now, your code is readable (hopefully) to us.

The second point. Sublime text does not include any AppleScript script definition, so you can not handle it with AppleScript.

TextEdit is scriptable, and probably you want in plain text rather than rich text (RTF) mode.

Tags: Mac OS & System Software

Similar Questions

  • Dreamweaver search / replacement of marked text no longer work

    Dreamweaver search / replacement of marked text no longer work

    When I mark a block of text and begin to replace a single string for example, DW replace only the first is the string a judgment of exploitation

    Try to update your version of DW Adobe - Dreamweaver Support Center: Updaters

  • How the process of searching / replacing text within brackets ([])

    Hello

    How the process of searching / replacing text within brackets ([]).

    I want to make the process so that the replacement inside text: ([]) this particular color and style of a particular paragraph.

    You try this option: (-[]) ([*. * \w*\d*)(\])

    Unfortunately, the process was not successfully that entirely, it does not determine if there is more than one paragraph.

    File test installation with photos.

    Sorry for mistakes in writing, I don't know English well.

    PDF + INDD

    http://www.up-00.com/?ggcf

    http://www.up-00.com/?QBcf


    Fonts:

    http://www.up-00.com/?ABcf

    Test_3.png

    Test_2.png

    Test_1.png

    Relevant if no Notes: (?s)\[.+?\]

    If not, this regular expression could play the game:   (?s)\[(~F?. *?) +\]

  • How rename (search/replace) par UN script styles sheets

    How rename (search/replace) the sheets of styles, par UN script?

    In order to remove all the "exotic" characters

    I think you chose the wrong forum. This forum, EST pour Acrobat JavaScript only.

  • Limit search / replace on a table or a spreadsheet

    Is it possible to limit the command find / replace for a selected table or spreadsheet (tab). When I try, search numbers in the entire workbook (all tabs). Excel do not have this limitation. Super annoying, especially since the soft seems to jump from a tab to the tab before answering all the tables in a tab.

    Hi Ty,

    Short answer: feature not available.

    By the numbers, "Worksheet", short for "spreadsheet" refers to the entire document, which may contain several "leaves", each of which can be consulted by clicking its tab at the top of the workspace.

    With the previous version, Numbers ' 09 (version 2.x) Find could be confined to the sheet current, or could search the entire Document. This feature (and many others) did not appear in the new numbering.

    Many extra features have been added to the new application, and have added several new (and useful) features that were not in Numbers ' 09.

    Unfortunately, the possibility of limiting a search to a single sheet or a single table is not (yet) a feature support 3 digit.

    If you want added, go to the menu number (in numbers), select provide feedback numbers and make your request.

    Kind regards

    Barry

  • Help update the values to modify files on Excel sheet

    I have an excel sheet containing a list of values that need to be updated daily. Cells that have values are related to certain cells in a separate file. The problem is that the file that gets my excel sheet is constantly updated values of as well as the file name. I want to create a macro that will be able to grab the values from the new file and update the spreadsheet I have. I tried to create a macro when you type the name of the file you want to the linked cells to, and she copy that and replace a formula that is already defined, so I'll be able to get new values. I'll show you an example below.

    Front of Macro

    Enter the name of the file: 12345

    (Part 1): = 'S:\MATERIALS\RAW matiere\ [135.xlsx] PURCHASE! $D $11

    During the Macro

    Enter the name of the file: 12345

    (Part 1): = 'S:\MATERIALS\RAW matiere\ [12345.xlsx] PURCHASE! $D $11

    (replaced the file name 135 with 12345)

    When I did that it worked, but my problem is that whenever I entered a new file name so that it is updated (for example 987), the cell would just update with the file I recorded the macro with (12345).

    If someone has a code VBA or other suggestions, I would really appreciate it! If you need me to explain more about this, feel free to let me know. Thank you

    The command of VBA macro to set the formula in a cell is:
    Range ("a6"). Formula = "= 1 + 1.

    This would create cell A6 of the formula "1 + 1 =", and the cell afficheraient a 2 it.
    Here is a full function VBA, you can use and customize.  Simply paste in your VBA Editor to use.  You can see the string which is the formula is to break with the prompting text in the middle.

    Void macroFunctionName()
    As Variant Dim promptText
    promptText = InputBox ("What number to the file name?", "Type number please")

    Range ("a6"). Formula = "='S:\MATERIALS\RAW matiere\ ["promptText & ".xlsx] PURCHASE '! $$D 11 "
    End Sub

  • How can I make a long list of search - replace only the master

    Hello world

    I had this script:

    //---------------------------------------------------------------------------------------- -------------------------------

    myDocuments var = app.documents.everyItem ();
    var myLayers = myDocuments.layers.everyItem ();

    Locked text on master blocks spreads are not affected.
    If you want to unblock, please add something like this:

    Unlock all elements of each document page on is spreading and Captain spreads (optional):
    myDocuments.pageItems.everyItem (.locked = false);

    var myPageItemsOnNormalSpreads = myDocuments.spreads.everyItem ().pageItems.everyItem ();

    Unlock the layers (optional)
    myLayers.locked = false;

    Lock all elements of page level first on normal spreads
    This leaves the elements on the page on unlocked master spreads:
    myPageItemsOnNormalSpreads.locked = true;

    Now for the GREP part:
    app.findChangeGrepOptions.includeMasterPages = true;
    app.findGrepPreferences = changeGrepPreferences = null;
    app.findGrepPreferences.findWhat = "\\b20\\d+\\b";

    Research on "all open document" level
    Which returns an array of arrays:
    var myTarget = myDocuments.findGrep ();

    Flattening of myTarget Bay:
    var flattenedFoundArray = [];

    for (var n = 0; n < myTarget.length; n ++) {}
    flattenedFoundArray = flattenedFoundArray.concat (myTarget [n]);
    };

    Change the content of the texts found in flat table:
    for (var n = flattenedFoundArray.length - 1; n > = 0; n-) {}
    flattenedFoundArray [n] .silence = String (Number(flattenedFoundArray[n].contents) + 1);
    };

    Unlock all objects on normal spreads:
    myPageItemsOnNormalSpreads.locked = false;

    Reset search GREP and edit the prefs:
    app.findGrepPreferences = changeGrepPreferences = null;

    //---------------------------------------------------------------------------------------- -------------------------------

    made by Uwe

    I change in this, to make a multi elements of search - replace only the master

    //==============================================================================

    myDocuments var = app.documents.everyItem ();
    var myLayers = myDocuments.layers.everyItem ();

    Locked text spreads masters frameworks are not affected.
    If you want to unblock, please add something like this:

    Unlock all items page of each document of spreads and master spreads (optional):
    myDocuments.pageItems.everyItem (.locked = false);

    var myPageItemsOnNormalSpreads = myDocuments.spreads.everyItem ().pageItems.everyItem ();

    Unlock the layers (optional)
    myLayers.locked = false;

    Lock all elements of page level first on normal spreads
    This leaves the elements on the page on unlocked master spreads:
    myPageItemsOnNormalSpreads.locked = true;

    Now for the GREP part:
    app.findChangeGrepOptions.includeMasterPages = true;
    app.findGrepPreferences = changeGrepPreferences = null;
    app.findGrepPreferences.findWhat = "USA";

    Research on "all open document" level
    Which returns an array of arrays:
    var myTarget = myDocuments.findGrep ();

    Flattening of myTarget Bay:
    var flattenedFoundArray = [];

    for (var n = 0; n < myTarget.length; n ++) {}
    flattenedFoundArray = flattenedFoundArray.concat (myTarget [n]);
    };

    Change the content of the texts found in flat table:
    for (var n = flattenedFoundArray.length - 1; n > = 0; n-) {}
    flattenedFoundArray [n] .silence = "CHINA";
    };

    Unlock all objects on normal spreads:
    myPageItemsOnNormalSpreads.locked = false;

    Reset search GREP and edit the prefs:
    app.findGrepPreferences = changeGrepPreferences = null;


    //---------------------------------------------------------------------------------------- -------------------------------

    myDocuments var = app.documents.everyItem ();
    var myLayers = myDocuments.layers.everyItem ();

    Locked text spreads masters frameworks are not affected.
    If you want to unblock, please add something like this:

    Unlock all items page of each document of spreads and master spreads (optional):
    myDocuments.pageItems.everyItem (.locked = false);

    var myPageItemsOnNormalSpreads = myDocuments.spreads.everyItem ().pageItems.everyItem ();

    Unlock the layers (optional)
    myLayers.locked = false;

    Lock all elements of page level first on normal spreads
    This leaves the elements on the page on unlocked master spreads:
    myPageItemsOnNormalSpreads.locked = true;

    Now for the GREP part:
    app.findChangeGrepOptions.includeMasterPages = true;
    app.findGrepPreferences = changeGrepPreferences = null;
    app.findGrepPreferences.findWhat = 'Washington DC';

    Research on "all open document" level
    Which returns an array of arrays:
    var myTarget = myDocuments.findGrep ();

    Flattening of myTarget Bay:
    var flattenedFoundArray = [];

    for (var n = 0; n < myTarget.length; n ++) {}
    flattenedFoundArray = flattenedFoundArray.concat (myTarget [n]);
    };

    Change the content of the texts found in flat table:
    for (var n = flattenedFoundArray.length - 1; n > = 0; n-) {}
    flattenedFoundArray [n] .silence = "Beijing."
    };

    Unlock all objects on normal spreads:
    myPageItemsOnNormalSpreads.locked = false;

    Reset search GREP and edit the prefs:
    app.findGrepPreferences = changeGrepPreferences = null;


    //===============================================================================

    only what I can do is to repeat and repeat again

    is this another perfect solution to do?

    Thank you

    Teetan

    Try this,

    findChange("USA", "CHINA");
    findChange("Washington DC", "Beijing");
    
    function findChange (findWhat, changeContent){
        var myDocuments = app.documents.everyItem();
        var myLayers = myDocuments.layers.everyItem();
        //Locked text frames on master spreads are not touched.
        //If you want to unlock them you have to add something like this:
        //Unlock ALL page items in every document on spreads and master spreads (optional):
        myDocuments.pageItems.everyItem().locked = false;
        var myPageItemsOnNormalSpreads = myDocuments.spreads.everyItem().pageItems.everyItem();
        //Unlock the layers (optional)
        myLayers.locked = false;
        //Lock all first level page items on normal spreads
        //That leaves the page items on master spreads unlocked:
        myPageItemsOnNormalSpreads.locked = true;
        //Now for the GREP part:
        app.findChangeGrepOptions.includeMasterPages = true;
        app.findGrepPreferences = changeGrepPreferences = null;
        if(findWhat)app.findGrepPreferences.findWhat = findWhat;
        //Do the search on "all open document" level
        //That will return an array of arrays:
        var myTarget = myDocuments.findGrep();
        //Flattening the myTarget array:
        var flattenedFoundArray = [];
        for(var n=0;n=0;n--){
            if(changeContent)flattenedFoundArray[n].contents = changeContent;
            };
        //Unlock all objects on normal spreads:
        myPageItemsOnNormalSpreads.locked = false;
        //Reset GREP find and change prefs:
        app.findGrepPreferences = changeGrepPreferences = null;
    }
    

    Vandy

  • Download must be a csv file, but download a text document

    http://www.arttimesjournal.com/data/events-August-2015.csv
    is the address that needs access to a csv file. Instead, I get a word document

    Opening of the site Web with Firefox looks like a text document. However, if you right click on [Save Page as...], events-August - 2015.csv (all files (*. *) and open it with a program such as Excel, it will appear correctly)

  • Insert new data to a new line in the same Excel sheet in continuous

    Hello world

    I'm using LabVIEW 2010 and there is a problem, I need to ask the subject to export the LabView to Excel data. Basically, I could transfer data "once" once on a new or selected Excel worksheet, but can only be 'IMMEDIATELY' when I run the VI, so my problem is, I need the data to be inserted at a same Excel sheet whenever I press run and the new data will replace not the former, instead go to the next new row or column. I really need answers regarding my problems, suggestions and ideas are welcome.

    I have attached my current VI and a picture describe the outcome that I needed

    Thank you for answer


  • copy the file directory into an Excel sheet

    How can I copy the file names in a directory/folder to an Excel spreadsheet? For example, I have 200 files in a folder. I want to copy the title of all the files in an Excel sheet to better management and add notes. Thank you

    I received an email go, but I can't respond to this e-mail address.
    Here is my supplementary question:
    "Thanks a lot for your help."
    It's one more step.
    But I want just the names of files on each cell in the Excel sheet, without the path. »

    Open the folder, and then select all the documents in question.

    Hold the shift key while clicking the right mouse button (shift + right click).
    Choose "copy as path".
    Return to the spreadsheet and choose "Paste" to paste the list of documents in the worksheet.
    This will paste the full path, including file name, of each document, as shown below.

    Is that what you meant? Please let us know.
    Best wishes
    BookwormDragon
  • Search &amp; replace confirmation

    I installed SQL Developer 4.0.0.13 and I'm not really fond of the new confirmation box search / replace.  Around the screen, it jumps to the next occurrence of the text being constantly have to hunt the box around the confirmation screen.  I'd rather have the features like pre - 4.0 versions that keep the box of confirmation in one place while stressing again the next shot.

    Is - this configurable?  I don't see this in the preferences.

    Thank you.

    No hunting around not required, just use the shortcut keys Alt + Y, Alt + N, Alt + A

  • Error while exporting the data in an Excel sheet

    Hi all

    I created a VO that is based on the query (not based on EO) and the query is as follows:

    Select f.user_name,
    f.Description,
    a.currency_code,
    a.amount_to,
    a.amount_from
    seacds.ar_approval_user_limits_nv a, seacds.fnd_user_nv f
    where a.user_id = f.user_id
    and a.document_type = 'CM '.
    order by 2;


    Based on this original Version I created a search page that searches for and returns the data in the table and the finally export standard button will export data in excel sheet.
    In this research data based on over 5 attributes. Without entering anything in the messageTextInput if I'm clicking on this button, it returns all the data in the region of the table. After that if I click on the button export, data are getting exported to the Excel sheet. It is very good.

    But if I'm looking for data by entering a value in one of the messageTextInput, it is returned from the data. But if I'm clicking on the export button then it throws the following error:

    The exception details.
    oracle.apps.fnd.framework.OAException: oracle.jbo.SQLStmtException: 27122 Houston: SQL error in the preparation of the statement. Statement: SELECT * FROM (select f.user_name,
    f.Description,
    a.currency_code,
    a.amount_to,
    a.amount_from
    seacds.ar_approval_user_limits_nv a, seacds.fnd_user_nv f
    where a.user_id = f.user_id
    and a.document_type = 'CM '.
    order by 2) QRSLT WHERE ((UPPER (CURRENCY_CODE) as UPPER(:1) AND (CURRENCY_CODE like: 2 OR CURRENCY_CODE as: 3 OR CURRENCY_CODE as: 4 OR CURRENCY_CODE as: 5))) ORDER OF DESCRIPTION asc
    at oracle.apps.fnd.framework.OAException.wrapperException (unknown Source)
    at oracle.apps.fnd.framework.webui.OAPageErrorHandler.prepareException (unknown Source)
    at oracle.apps.fnd.framework.webui.OAPageErrorHandler.processErrors (unknown Source)
    at oracle.apps.fnd.framework.webui.OAPageBean.processFormRequest (unknown Source)
    at oracle.apps.fnd.framework.webui.OAPageBean.preparePage (unknown Source)
    at oracle.apps.fnd.framework.webui.OAPageBean.preparePage (unknown Source)
    at oracle.apps.fnd.framework.webui.OAPageBean.preparePage (unknown Source)
    in OA. jspService(_OA.java:71)
    at com.orionserver.http.OrionHttpJspPage.service(OrionHttpJspPage.java:59)
    at oracle.jsp.runtimev2.JspPageTable.service(JspPageTable.java:462)
    at oracle.jsp.runtimev2.JspServlet.internalService(JspServlet.java:594)
    at oracle.jsp.runtimev2.JspServlet.service(JspServlet.java:518)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
    at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:713)
    at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:370)
    at com.evermind.server.http.HttpRequestHandler.doProcessRequest(HttpRequestHandler.java:871)
    at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:453)
    at com.evermind.server.http.HttpRequestHandler.serveOneRequest(HttpRequestHandler.java:221)
    at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:122)
    at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:111)
    to oracle.oc4j.network.ServerSocketReadHandler$ SafeRunnable.run (ServerSocketReadHandler.java:260)
    to com.evermind.util.ReleasableResourcePooledExecutor$ MyWorker.run (ReleasableResourcePooledExecutor.java:303)
    at java.lang.Thread.run(Thread.java:595)
    # # 0 in detail
    java.sql.SQLException: invalid column type
    at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:138)
    at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:175)
    at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:240)
    at oracle.jdbc.driver.OraclePreparedStatement.setObjectCritical(OraclePreparedStatement.java:7895)
    at oracle.jdbc.driver.OraclePreparedStatement.setObjectInternal(OraclePreparedStatement.java:7572)
    at oracle.jdbc.driver.OraclePreparedStatement.setObjectInternal(OraclePreparedStatement.java:8183)
    at oracle.jdbc.driver.OraclePreparedStatement.setObjectAtName(OraclePreparedStatement.java:8206)

    Please give me any idea to clear this error.

    Thank you and best regards,
    Myvizhi

    Hi all

    I solved the problem... I put the property to select all of the lines as false. So now I'm able to export data.

    Thank you and best regards,
    Myvizhi

  • How can I search - replace in master pages only?

    Hello world

    How can I search - replace in master pages only?

    for example:

    I want to change in 2013-2014, but only in master pages.

    in master pages for all of the open files.

    How can I do?

    Teetan

    Hi Teetan,

    To set a goal is more of halfway to creation script.

    Check this box:

    app.doScript('main()', ScriptLanguage.JAVASCRIPT, undefined, UndoModes.FAST_ENTIRE_SCRIPT, "grow numbers on masters");
    function main() {
      catchOption = app.findChangeGrepOptions.includeMasterPages;
      app.findChangeGrepOptions.includeMasterPages = true;
      app.findGrepPreferences = changeGrepPreferences = null;
      app.findGrepPreferences.findWhat = "\\b\\d+\\b";
    
    var
      mTarget = app.documents.everyItem().masterSpreads.everyItem().textFrames.everyItem(),
      mFound = mTarget.findGrep(),
      mConFound = [],
      len = mFound.length;
    
      if (len && mFound[0].constructor.name == "Array")
           while (len-->0)
                mConFound = mConFound.concat(mFound[len]);
    
      len = mConFound.length;
      while (len-->0) {
           mConFound[len].contents = String(Number(mConFound[len].contents) + 1);
      }
      app.findChangeGrepOptions.includeMasterPages = catchOption;
    }
    

    Jarek

  • Report - error in Excel-sheet Manager

    I have a report FSG and want to work with Report Manager to create reports Excel of it.

    This works very well for pdf and html, but Excel sheets gives a Macro-erreur: "compile error: a variable is not set.
    It refers to a variable Sheet1, which is (probably) not there since my client works in Dutch, and the leaves are called Blad1 etc.

    Can it be solved without having to work with the English version Excel?

    Kind regards
    Roel

    Please see these documents.

    VBasic error display in Excel FSG with Manager reports [ID 787201.1]
    Variable error Visual Basic do not set, while the opening has published the report in Excel [ID 882847.1]

    Is there an XML model for running the FSG reports in Excel? [302980.1 ID]
    11.5 the Manager reports to: white sheet Excel when look at an exit Excel FSG [ID 882264.1]
    Impossible to publish the report of the FSG in Excel only a blank Page appears [ID 749998.1]
    Publish the report FSG to Excel, Excel opens but no report no displayed - sheet blank work [1064856.1 ID]
    Blank Page when you try to view FSG in Manager reports Via Excel [ID 331686.1]

    Thank you
    Hussein

  • Script a search/replace using a data source

    So I wrote a program (c#) a few years ago which basically opens a file, InDesign Exchange, doing a search/replace, based on a datasourse SQL table and then our graphics people would just convert the INX file in InDesign and ultimately in PDF format.  Too many steps.

    There are more than 2,500 pieces of variable data in each file, so a product like DesignMerge is not practical.  Our database consists mainly of 2 fields [LookFor] and [ReplaceWith], I would like an Indesign script that will just run through the data file and do a find/replace for each record.  Is this feasible and what someone has suggestions or starting points?

    Thank you!

    No, it doesn't matter what format to use: text delimited csv or tab. Of course you can leave it as it is.

Maybe you are looking for