i microsoft.public.mac.office.word skrev Daiya Mitchell
Sun, 18 May 2008 06:54:17 -0400 (-), i en artikel med
ID <#Cf9DWNuIHA.3604@[EMAIL PROTECTED]
>
og titlen "Re: VBA to return in the next version of Office Mac !?",
følgende:
Hi
: Hi Mitrokhin,
:
: Mitrokhin wrote:
: > Indeed, Applescript seems to be very well integrated. I've also found
: > that in most cases the rewriting wasn't as hard as I expected (guees
it
: > helped having the MacTech guide close at hand too :), but alas
there're
: > a couple of macros I just can't convert (more due to my own lack of
: > skills than anything else)
:
: If you have any macro replacement scripts you think would be useful for
: other people, I'd love to link them from here. Have you put them on
: Scriptbuilders.net or anything, perhaps?
: http://word.mvps.org/Mac/scripts/
:
No I havn't, see, my use of macros in word just might be very
idiosyncratic and then there's the question about coding quality: i'm
pretty far from being a programming whiz but you be the judge, would
eg. these hold an interest for other people (beware of linebreaks) ?
1. Toogle highlight on the selection or the whole line. Chose among
some predetermined highlightcolors.
2. Find the first occurence of a specially named bookmark from the
current ip to the end of the doc (if found go to said bookmark and
delete it) OR insert a bookmark at the current ip and highlight the
selection/line.
(yep I like highlighting stuff)
1. Toogle Highlight etc.
======
tell application "Microsoft Word"
if selection's selection type = selection ip then
expand the selection by a line item
-- chop off the paragraph mark
set r to create range active do***ent start ¬
(selection's selection start) end ((selection's selection end)
- 1)
collapse range text object of selection direction collapse start
my highlightChange(r)
else
-- again chop off some superfluous chars
if (content of selection) ends with " " or (content of selection)
ends with return then
set selection's selection end to ((selection's selection end)
- 1)
end if
my highlightChange(text object of selection)
collapse range text object of selection direction collapse end
end if
end tell
on highlightChange(range)
tell application "Microsoft Word"
if highlight color index of range = no highlight then
set highlight color index of range to (my PickFarve())
else
set highlight color index of range to no highlight
end if
end tell
end highlightChange
on PickFarve()
set FarveListe to {"blue", "turquoise", "bright green", "violet", ¬
"yellow", "green", "pink"}
set FarveKoder to {2, 3, 4, 5, 7, 11, 12}
set the farve to (choose from list the FarveListe with prompt "Vælg
en farve:") as Unicode text
if farve is "false" then error number -128
repeat with i from 1 to the count of FarveListe
set denne_her to item i of the FarveListe
if denne_her is the farve then
set the opslagsKode to i
exit repeat
end if
end repeat
return item opslagsKode of FarveKoder
end PickFarve
====
2. Insert/go to bookmark
tell application "Microsoft Word"
-- fra IP/markeringen + 1 og frem
set r to (create range active do***ent start ((selection's selection
end) + 1) ¬
end (end of content of text object of active do***ent))
try
set bmk to first item of (get every bookmark of r whose name
contains "MARK")
set bmkRange to text object of bmk
select bmkRange
tell selection
set highlight color index of text object to auto
collapse range (text object of selection) direction collapse
start
end tell
delete bookmark (name of bmk) of active do***ent
on error
-- ingen bogmærker med navnet mark. Opret et i markeringen
-- der kan dog være "MARK" bogmærker tidl. i dokumentet
if not (exists (bookmark "MARK" of active do***ent)) then
set bmkNavn to "MARK"
else
set i to 1
repeat
if not (exists (bookmark ("MARK" & i) of active do***ent))
then
set bmkNavn to "MARK" & i
exit repeat
end if
set i to 1 + 1
end repeat
end if
tell selection
if selection type = selection ip then expand by a line item
set selection end to ((selection end) - 1)
set highlight color index of text object to violet
end tell
make new bookmark at selection with properties {name:bmkNavn,
text object:(text object of selection)}
collapse range (text object of selection) direction collapse start
end try
end tell
: Daiya
:
--
Hilsen
Mitrokhin.


|