Search code examples
ms-wordapplescriptword-style

Rename style name in Word via Applescript


I wanna change the style name from "bib" to "bibliography" via Applescript. My script runs no error but style name not been changed. Anyone can help this?

Here is my script to rename style name:

tell application "Microsoft Word" to activate
tell application "Microsoft Word"
    if exists (Word style "bib" of active document) then
        set filename to full name of active document
        organizer rename source filename name "bib" new name "bibliography" organizer object type organizer object styles
    end if
end tell

However, delete style "bib" works via this script:

tell application "Microsoft Word" to activate
tell application "Microsoft Word"
    if exists (Word style "bib" of active document) then
        set filename to full name of active document
        organizer delete source filename name "bib" organizer object type organizer object styles
    end if
end tell

Solution

  • tell application "Microsoft Word"
        activate
        if exists (Word style "bib" of active document) then
            set name local of Word style "bib" of active document to "bibliography"
        end if
    end tell