Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Mac > Word for Mac > Re: VBA to retu...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 13 of 19 Topic 9869 of 12131
Post > Topic >>

Re: VBA to return in the next version of Office Mac !?

by Mitrokhin <Mitrokhin@[EMAIL PROTECTED] > May 19, 2008 at 10:23 AM

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.
 




 19 Posts in Topic:
VBA to return in the next version of Office Mac !?
Mitrokhin <Mitrokhin@[  2008-05-16 08:08:45 
Re: VBA to return in the next version of Office Mac !?
Daiya Mitchell <daiyaN  2008-05-16 09:13:55 
Re: VBA to return in the next version of Office Mac !?
korventeen@[EMAIL PROTECT  2008-05-16 09:18:40 
Re: VBA to return in the next version of Office Mac !?
Phillip Jones <pjones1  2008-05-16 17:26:45 
Re: VBA to return in the next version of Office Mac !?
korventeen@[EMAIL PROTECT  2008-05-16 16:38:46 
Re: VBA to return in the next version of Office Mac !?
"Phillip Jones, CET&  2008-05-17 17:18:28 
Re: VBA to return in the next version of Office Mac !?
Jim Gordon MVP <goldke  2008-05-17 12:03:29 
Re: VBA to return in the next version of Office Mac !?
Phillip Jones <pjones1  2008-05-18 11:51:01 
Re: VBA to return in the next version of Office Mac !?
JE McGimpsey <jemcgimp  2008-05-20 08:43:16 
Re: VBA to return in the next version of Office Mac !?
John McGhie <john@[EMA  2008-05-18 08:33:36 
Re: VBA to return in the next version of Office Mac !?
Mitrokhin <Mitrokhin@[  2008-05-18 10:35:06 
Re: VBA to return in the next version of Office Mac !?
Daiya Mitchell <daiyaN  2008-05-18 06:54:17 
Re: VBA to return in the next version of Office Mac !?
Mitrokhin <Mitrokhin@[  2008-05-19 10:23:07 
Re: VBA to return in the next version of Office Mac !?
Daiya Mitchell <daiyaN  2008-05-19 19:27:49 
Re: VBA to return in the next version of Office Mac !?
Mitrokhin <Mitrokhin@[  2008-05-20 09:56:43 
Re: VBA to return in the next version of Office Mac !?
John McGhie <john@[EMA  2008-05-18 21:26:01 
Re: VBA to return in the next version of Office Mac !?
Mitrokhin <Mitrokhin@[  2008-05-19 10:23:16 
Re: VBA to return in the next version of Office Mac !?
Phillip Jones <pjones1  2008-05-18 12:04:37 
Re: VBA to return in the next version of Office Mac !?
Jim Gordon MVP <goldke  2008-05-19 19:34:23 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Thu Dec 4 18:06:27 CST 2008.