• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Making text plain or bold in Word
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Making text plain or bold in Word


  • Subject: Re: Making text plain or bold in Word
  • From: "Oz.Springs" <email@hidden>
  • Date: Fri, 11 Apr 2003 21:17:50 +0100

Thank you very much Paul. I have just tested this out and it works. It is _super_ fast.

Kind regards



Oz


At 12:32 -0700 11/04/2003, Paul Berkowitz wrote:
>You should not be including the Sub/End Sub when using in 'do Visual Basic'.
>And just as in regular AppleScript, you should not use Selection when it's
>not necessary - it's clunky and slower. 'Words' in VB can consist just of
>tabs or other white space, and should be excluded. It's possible that Normal
>style will not be plain text although it is, virtually always true enough,
>with the user's default font (usually Times) which is plain enough, I'm
>sure. Then you can just set the style to Normal and - most important - Reset
>the Font to remove manually applied formatting.
>
>I haven't been able to discover any generic "white space" constant in VBA,
>so I check to make sure that a 'word' has at least one character with an
>ASCII number higher than 32 (i.. a visible character). When I first tested
>this without that check it found all the tabs in my first line as "words" so
>the real words never got bolded.
>
>This script is super fast, with no clunky selecting going on:
>
>tell application "Microsoft Word"
>
> do Visual Basic "
>Dim myStory As Variant
>Dim myWord As Variant, char As Variant
>Dim i As Integer, c As Integer, w As Integer
>
>For Each myStory In ActiveDocument.StoryRanges
> myStory.Style = wdStyleNormal
> myStory.Font.Reset
>Next myStory
>
>i = 0
>w = 0
>c = ActiveDocument.Words.Count
>For Each myWord In ActiveDocument.Words
> i = i + 1
> For Each char In myWord.Characters
> If Asc(char) > 32 Then
> myWord.Font.Bold = True
> w = w + 1
> Exit For
> End If
> Next char
> If w = 2 Or i = c Then Exit For
>Next myWord
>"
>end tell
>
>
>
>--
>Paul Berkowitz
>
>
>
>> From: "Oz.Springs" <email@hidden>
>> Date: Fri, 11 Apr 2003 19:36:38 +0100
>> To: email@hidden
>> Subject: Re: Making text plain or bold in Word
>>
>> Yes, it is easy if you get Applescript to call up some Visual Basic. "Plain
>> text" in Word is usually called "Normal" style and you will have to set the
>> fonts and other characteristics yourself to get what you want, for example
>> using Courier, the plainest of plain fonts. Note, however, that Courier may
>> not be able to print in Bold.
>>
>> Here is the VB part of your script:
>>
>> Sub change_style()
>> '
>> ' change_style Macro
>> ' Selection.WholeStory
>> Selection.Style = ActiveDocument.Styles("Normal")
>> Selection.Style = ActiveDocument.Styles("Default Paragraph Font")
>> Selection.HomeKey Unit:=wdStory
>> Selection.MoveRight Unit:=wdWord, Count:=2, Extend:=wdExtend
>> Selection.Font.Bold = wdToggle
>> End Sub
>>
>> HTH
>>
>>
>>
>> Oz
>>
>>> This is probably simple, but I am pulling my hair out over it.
>>>
>>> All I want to do is change all text in an opened Word document to "plain",
>>> then change the first two words of text to "bold".
>>>
>>> Easy, I hope?
>> _______________________________________________
>> applescript-users mailing list | email@hidden
>> Help/Unsubscribe/Archives:
>> http://www.lists.apple.com/mailman/listinfo/applescript-users
>> Do not post admin requests to the list. They will be ignored.
>_______________________________________________
>applescript-users mailing list | email@hidden
>Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/applescript-users
>Do not post admin requests to the list. They will be ignored.
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.

References: 
 >Re: Making text plain or bold in Word (From: Paul Berkowitz <email@hidden>)

  • Prev by Date: Re: Space in POSIX path/Terminal shell
  • Next by Date: OS X 10.2.5 and AppleScript
  • Previous by thread: Re: Making text plain or bold in Word
  • Next by thread: Re: Making text plain or bold in Word
  • Index(es):
    • Date
    • Thread