Applescript select text range between 2 markers

Version: 2008
Operating System: Mac OS X 10.5 (Leopard)
Processor: Intel

Try as I may I just can't figure this one out. In my word document I have sections of text which are delimited by a markers. I want to be able to italicize the text between the markers. To do this, I presume I need to set the text range, or possibly selection, as the text between these two markers. And this has got me stumped. <br><br>I'm able to find and select the first marker, and then find and select the second marker, but how do I then select the text between these two markers. <br><br>Example text is: <br><br>&quot;More then three centuries after the $Flying Scotsman% was brought into service, it looks like the famous name $may be back% in service.&quot;  <br><br>I want to be able to italicize the text between the markers $ and %, so in the example above it would be &quot;Flying Scotsman&quot; and &quot;may be back&quot;. <br><br>Any help greatly appreciated.
0
mikeyt
2/7/2010 12:17:04 AM
mac.office.word 1676 articles. 1 followers. Follow

3 Replies
2475 Views

Similar Articles

[PageSpeed] 30

I can't do this in AppleScript, but it's very similar to the way you do it
in VBA.

You can use either the range or the selection object, then use the Extend
method:

Selection.Extend Character:="%"

That will extend the selection right until the first % sign.  You need to
somehow protect against a "runaway" condition if there is any possibility
that the % sign may not be there.

However, you can do this with the Replace tool without needing  script:

In Find/Replace, set $*% as your Find string.

Specify "Use wildcards" so the * matches "any number of characters" so you
are not searching for $<any characters>%

In the Replace box, specify Format>Font>Italic.  Make sure the Replace box
contains no characters, and ... voila!

Hope this helps

On 7/02/10 8:17 AM, in article 59bb2628.-1@webcrossing.JaKIaxP2ac0,
"mikeyt@officeformac.com" <mikeyt@officeformac.com> wrote:

> Version: 2008 Operating System: Mac OS X 10.5 (Leopard) Processor: Intel Try
> as I may I just can't figure this one out. In my word document I have sections
> of text which are delimited by a markers. I want to be able to italicize the
> text between the markers. To do this, I presume I need to set the text range,
> or possibly selection, as the text between these two markers. And this has got
> me stumped. 
> 
> I'm able to find and select the first marker, and then find and select the
> second marker, but how do I then select the text between these two markers.
> 
> Example text is: 
> 
> "More then three centuries after the $Flying Scotsman% was brought into
> service, it looks like the famous name $may be back% in service."
> 
> I want to be able to italicize the text between the markers $ and %, so in the
> example above it would be "Flying Scotsman" and "may be back".
> 
> Any help greatly appreciated.

This email is my business email -- Please do not email me about forum
matters unless you intend to pay!

 -- 

John McGhie, Microsoft MVP (Word, Mac Word), Consultant Technical Writer,
McGhie Information Engineering Pty Ltd
Sydney, Australia. | Ph: +61 (0)4 1209 1410
+61 4 1209 1410, mailto:john@mcghie.name


0
John
2/7/2010 2:25:46 AM
That was definitely of some help, and i can find the items between markers using the wildcard. What I now want to know if it is possible to mimick the &quot;Highlight all items found&quot; feature in the applescript. <br><br>With this sample text: &quot;More then three centuries after the $Flying Scotsman% was brought into service, it looks like the famous name $may be back% in service.&quot; <br><br>I can now use this applescript to find and select the first occurrence - i would like to be able to highlight ALL occurrences though: <br><br>CODE: <br>
tell application &quot;Microsoft Word&quot; <br>
&nbsp;&nbsp;set selection to null <br>
&nbsp;&nbsp;set selfind to find object of selection <br>
&nbsp;&nbsp;set forward of selfind to true <br>
&nbsp;&nbsp;set wrap of selfind to find continue <br>
&nbsp;&nbsp;set match wildcards to true <br>
&nbsp;&nbsp;set content of selfind to &quot;($)*(%)&quot; <br>
&nbsp;&nbsp;execute find selfind <br>
end tell <br><br>I'm looking in the dictionary for any clues as to the &quot;Highlight All Found&quot; but no luck. Anyone else know?
0
mikeyt
2/7/2010 1:49:09 PM
Use the Replace object to replace the text formatting.  There are multiple
options on the Format tab, including bold, italic, highlighting, colours.
No marching red ants any more (thank god...) but almost everything else is
available.

Then Execute your Find with Replace All set to True :-)

Cheers


On 7/02/10 9:49 PM, in article 59bb2628.1@webcrossing.JaKIaxP2ac0,
"mikeyt@officeformac.com" <mikeyt@officeformac.com> wrote:

> That was definitely of some help, and i can find the items between markers
> using the wildcard. What I now want to know if it is possible to mimick the
> "Highlight all items found" feature in the applescript.
> 
> With this sample text: "More then three centuries after the $Flying Scotsman%
> was brought into service, it looks like the famous name $may be back% in
> service." 
> 
> I can now use this applescript to find and select the first occurrence - i
> would like to be able to highlight ALL occurrences though:
> 
> CODE: 
> tell application "Microsoft Word"
>   set selection to null
>   set selfind to find object of selection
>   set forward of selfind to true
>   set wrap of selfind to find continue
>   set match wildcards to true
>   set content of selfind to "($)*(%)"
>   execute find selfind
> end tell 
> 
> I'm looking in the dictionary for any clues as to the "Highlight All Found"
> but no luck. Anyone else know?

This email is my business email -- Please do not email me about forum
matters unless you intend to pay!

 -- 

John McGhie, Microsoft MVP (Word, Mac Word), Consultant Technical Writer,
McGhie Information Engineering Pty Ltd
Sydney, Australia. | Ph: +61 (0)4 1209 1410
+61 4 1209 1410, mailto:john@mcghie.name


0
John
2/9/2010 4:55:49 AM
Reply:

Similar Artilces:

fill series #2
I have a worksheet that has 8 columns and 105 rows. Each cell gets the data from another sheet in the workbook. I can't seem to be able to fill down the formula the way I need it. The first row in the first column gets the data from 'Daily Data'!A8, the second row would be 'Daily Data'!A18, third row 'Daily Data'!A28, and so forth. So each row needs to skip down 10 rows to get the next value. How can I do this by using fill series or the fill handles? I've tried both and can't seem to get it to work. I don't mind entering the formulae in the first couple...

SETUP BOOTSTRAPPER PROBLEM OFFICE 2000 prevents CD 2 installati...
I'm using Office 2000 Word, Excel and Access and have installed or reinstalled it from CD 1 three times on 8-month old XP Home Edition, no problem. Now I would like to install CD 2 programs and use Publisher. When CD 2 is inserted I get message, "MS Office setup bootstrapper has encountered a problem and needs to close. I can read some files on CD 2 but not the setup.hlp. I installed CD 2 on previous computer but never used programs. My latest reinstall of CD 1 was for purpose of getting a prompt to continue with CD 2, which didn't happen. I think when I installed CD 2 on o...

IF Function for column containing text
I have a Column of pricing from a csv. file that has TBA in some rows (price to be announced). I would like to change TBA to a 0. I have started with =IF(E1="TBA", ??? I also have a coded price column for cost price and would like to get rid of the letter code and also change remaining price to a 2 decimal cost. I've been reading and trying all kinds of things. I really need an IF function for the first column and am not sure what I need for the second. Any help really appreciated For the TBA thing: Select the column in question Goto the menu Edit>Replace Find ...

Inventory Reconciliation #2
Greetings, We have come across an issue that is related to Inventory Qty on hand.When we processed IV reconcilations, the inventory qty doubled and on running again,the total qty triples.On running the checklink, it notifies as Item on hand qty does not match with Purchase Receipts. We are using Manufacturing and IV is also tracked by LOTS. We had an opening balance as of 31st December 2007.in the Item stock Inquiry Window, the opening adjust is displayed with all the other transactions that followed.The main issue is that wrong qty is displayed in the BALANCE field. Any help on this mat...

AppleScript how to save a message
Version: 2008 Operating System: Mac OS X 10.5 (Leopard) Processor: Intel Email Client: pop I'd like to save a message via AppleScript, given its ID. The script below works rather well, except for the fact that when I reimport the mbox file, the message is enclosed in a folder it creates, to the name of the mbox file. <br><br>tell application &quot;Microsoft Entourage&quot; <br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;set lemessage to message id 85250 <br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n...

Track 2
Hi guy, I've a doubt: I read around the Internet that Track2 of Credit Card are made up of 40 character (see here http://www.ded.co.uk/magnetic-stripe-card-details.html). Now I've a smart card reader and I'm reading my cards but the Start sentinel, End Sentinel and LRC characters are not displayed/readed. So I'm asking if they are truly written in the card? ...

Enums, Combobox, Best Way to List and Select
Is there a simply way to list Enum choices in a combobox and then use the selection? "David" <dw85745NOT@earthlink.net> wrote in message news:uEwiq2xgKHA.5528@TK2MSFTNGP05.phx.gbl... > Is there a simply way to list Enum choices in a combobox and > then use the selection? Yes, and it involves Excel or similar spreadsheet program. See this post for details: http://groups.google.com/group/microsoft.public.vb.general.discussion/msg/1f9b4717253fd3e4 "Nobody" <nobody@nobody.com> wrote in message news:eFOJNjygKHA.4872@TK2MSFTNGP05...

How to select a sheet and input data into certain cells
I have 36 sheets, sheet1 is my menu, also on sheet1 I created in colum AB1=1stQTR AC1=2ndQtr AD1=3rdQTR AE1=4thQT AA2=2004 Sheet2 Sheet3 etc . . . AA3=2005 Sheet6 Sheet AA4=2006 Sheet8 Sheet AA5=2007 Sheet4 Sheet I would like to be able to select a year and a quarter and it goes to the sheet, i.e 2005 2ndQtr goes to sheet5 and in a couple of cells input 2005 and 1st Quarter I would also like to be able to print sheet5 and ask me if I want to print it agai or close and upon closing go back to sheet Is there an...

Variable Range in Formula
I'm stuck on this one, hopefullly someone can help. I have the following formula: =SUMPRODUCT((B2>=$B$5)*(B2<=$B$6)) Well "B2" in this formula is supposed to a variable range, but it wont calculate right. So I created a bunch of different range names on sheet2 (i.e., B1:B100, A3:A7, etc...), and in B2 of sheet1 I created a combobox with the validation tool for the user to basically choose the ranges I created. So if they choose let's say the B1:B100 range in B2, how will that work in the above formula? Thanks, ~Gabe Use the INDIRECT function. ...

Format cells if hovered over or selected
I want to be able to show visually which cells are linked to a cell when the cell is either hovered over or selected. For example: If A1 is selected/hovered over I want cells A5, B8, and B10 to highlight/change colors. Does anyone know of a way to do this in VBA, I'm pretty sure it can't be done using conditional formatting tool. Thanks. -Adam If you double click a cell containing a formula, the cells it refers to will be bordered in different colours. Also, if you click in the formula bar, you will get the same effect "Adam R" wrote: > I want to be able to s...

Consolidate data with text
Excel Consolidate Data does not consolidate text. I need to somehow combine data from several different worksheets into one (the sheets contain text and numbers). The tables on each sheet are set up identically with identical column headers. Ideally, I would like to import worksheet #1, then beginning on the first blank row after worksheet #1, import (or copy and paste) worksheet #2, etc to form one combined database. Ideas, please? I should have mentioned these worksheets are in different workbooks. Ron de Bruin has tons of code samples for combining data here: http://www....

Select multipul 'Page' items in a Pivot Table
Hi, I have a Pivot Table with 9 'Page' items. But I can only choose either 'All' or just one from each of the lists. Is there a way to get the 'check boxes' in the 'Page' part - ie the same as in the 'Row' data please? I've put the Page items into the Row but this makes my sheet too wide to fit all the columns on the page. Any ideas are greatly appreciated. Thanks in advance, AW You can't get check boxes in the page field in Excel 2000. To hide items you can do the following: In the pivot table, double-click the page field button. In ...

move a text box to the back
Hi, does anyone have any idea how to move a text box behind the cells in Excel. I'd like to add a "watermark" to the file like you can in Word but it's not working in Excel. I've tried the whole thing where the help feature tells you to select the object and go to draw then order then send to back. ...

COM OBJECT #2
WHEN I RING UP A SALE AND HIT THE+ KEY I GET AN ERROR MESSAGE (ATTEMPT TO EXECUTE COM OBJECT SIGNATURE.CAPTURE FAILED COULD NOT CREATE OBJECT) Do you have a signature capture device connected to the register? It appears as if it is set up under "Registers" in Store Operations Manager, but the software doesn't see it. "WPALMER72" wrote: > WHEN I RING UP A SALE AND HIT THE+ KEY I GET AN ERROR MESSAGE (ATTEMPT TO > EXECUTE COM OBJECT SIGNATURE.CAPTURE FAILED COULD NOT CREATE OBJECT) Did you get all of the OPOS stuff straight with your Epson receipt print...

Publisher 2003 "2 page document changes to 3 page"
I have couple of files created in Publisher 2003 which worked fine on my computer until the hard drive crashed. After the recovery the text in the file reflows on the 3rd page and automatically. The same files work fine on another computer. The printer for both th computers is same i.e. "HP Laserjet 2840". I also tried Microsoft document image writer as the default printer. I later formatted my computer again and still the same thing happens. The file works fine and prints fine on another computer but in my computer the text flows on the 3rd page inspite of the font size bein...

display zero values in selected cells
...

CFileDialog selecting directorys only
I Have a CFileDialog and I just want to be able to select directorys no files. Can this be done? use SHBrowseForFolder http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/shell/reference/functions/shbrowseforfolder.asp HTH, "Chris Baker" <ChrisBaker@discussions.microsoft.com> wrote in message news:5185346E-6097-4B9C-89B1-D6588C87249A@microsoft.com... >I Have a CFileDialog and I just want to be able to select directorys no >files. > > Can this be done? > You also might take a look at www.codeproject.com/dialog/cfolderdialo...

preventing allocation for a range of items
Hello: In GP 10.0, is it possible to turn off lot and bin allocation only for a range of items? childofthe1980s ...

How to go back to last selected cells?
Hello How to go back to last selected cells? Hi Dmitri, Try something like: '===================>> Public Sub Tester03() Dim rng As Range Dim rCell As Range Set rng = Selection Set rCell = ActiveCell 'your code, e.g. Range("A1").Select rng.Select rCell.Activate End Sub '<<=================== However, the above code would not normally be needed because it is rarely necessary, or desirable, to make selections, --- Regards, Norman "Dmitry Kopnichev" <kopn@bk.ruDelete> wrote in message news:uzAUQ1%23...

how to support multiple selection in treeview?
Hi, It seems that CTreeCtrl doesn't support multiple items selection. Is it correct? Its member function GetSelectedItem() returns "the" selected item. Then how do we allow multiple selections? Any help is appreciated. JD >It seems that CTreeCtrl doesn't support multiple items selection. Is it >correct? Its member function GetSelectedItem() returns "the" selected item. >Then how do we allow multiple selections? Any help is appreciated. Although it's not multiple selection as such, each item can have a check box if you use TVS_CHECKBOXES...

Destination selection message
Version: 2008 Operating System: Mac OS X 10.5 (Leopard) Processor: Intel I am having trouble installing Office 2008 update 12.1.7 as it says; "! You cannot install Office 2008 update 12.1.7 Update on this volume (being the Mac HD). A version of the software required to install this update was not found on this volume." and the only option is to cancel the update. Is there anything I am doing wrong or anything I can try to make the update run? The information here should be helpful: http://www.entourage.mvps.org/error/install_update.html -- HTH |:>) Bob Jones Office:Mac MVP ...

Design advice for this "Many text objects" collection project
I'd like to build a MFC app that has a split window with the left side showing a CTreeview and on the right a view that shows the (text) contents of the tree node currently selected. The tree-side would be build as a "normal" explorer view allowing add/delete/move folders. As the user clicks from folder to folder the right view shows the text contents instantly (ie no more clicks needed). There are several public domain version of such programs but the ones I've seen always seem to have something about them I don't like. Eg one enforced "save upon exit" - it wa...

Applescript vs. Excel
Version: 2004 Operating System: Mac OS X 10.5 (Leopard) Processor: Intel Okay... ive gotta prob. <br><br>At work, i must creat an table with excel... first i use excel 2004 and build some macros and all works... but then, me boss give me the order to update the table for office 2008... now, ther is the problem. Macros doesnt work in excel 2008. i switch to applescript... but is it possible to &quot;save&quot; the formated cells? like an form in word? <br><br>so long... > This message is in MIME format. Since your mail reader does not understand this f...

setting text in 1 cell from values in other
hello, I think this is pretty easy. but cannot get it. I have 2 cells. lets say A1 and B1. in B1 I have text. I want to set the value of A1 to 100, if B1 contains the values "ABC" or "DEF". B1 can contain a lot of text. not exact values. can anyoe help me out with this? thanks. One way =IF(SUMPRODUCT(COUNTIF(B1,{"*ABC*","*DEF*"}))>0,100,"") -- HTH Bob Phillips (remove nothere from email address if mailing direct) "bp" <x@y.com> wrote in message news:uk%238NagQGHA.5924@TK2MSFTNGP09.phx.gbl... > hello, &...

Excel-Export a file as a Fixed Length Text file
Can anyone advise on how to export/save an Excel file to a fixed length text file? Here's a thread that offers a couple of alternatives: http://groups.google.com/groups?threadm=40E61859.7071CC5A%40msn.com RJM wrote: > > Can anyone advise on how to export/save an Excel file to a fixed length text file? -- Dave Peterson ec35720@msn.com ...