Skip to content

Microsoft Office Mac Crashes Automated Fix

March 26, 2013

Perl Script to fix Microsoft Office 14 on MAC OSX 10.8.
Please check this other post for more details.

#!/usr/bin/perl
# This script checks the filenames in a directory and report for any broken symbolic links
# Author: BigDiver
# Version 1.0
# Date: 03/26/2013

# Office version
my $version = 14;

# Office install directory
my $office_dir = "/Applications/Microsoft Office 2011/";

use File::Find ();

die("Dir not found: " . $office_dir) if( ! -d $office_dir );
my %broken;
my $user = `whoami`;
chomp $user;

if( $user !~ /root/i ) {
    print "Script running as user $user\n";
    print "You must run this script as root. Try sudo $0\n";
    exit(-1);
}

print "Office Directory: $office_dir\n";
print "Office Version: $version\n";

File::Find::find({wanted => \&wanted}, $office_dir); # Calling wanted subroutine which use stat function to match broken links

foreach $d (keys %broken) {
    print "Fixin $d\n";
    unlink $d . "/Resources";
    symlink "$d/Versions/$version/Resources", "$d/Resources";
    unlink "$d/Versions/Current";
    symlink "$d/Versions/$version", "$d/Versions/Current";
}
print "Done\n";

sub wanted {
    my $file = $_;
    if (-l $file) {
        my $target = readlink $file;
        if ( ! -e $target && ! -l $target ) {
            my $dir = $File::Find::dir;
            $dir =~ s/\.framework.+$/\.framework/;
            $broken{$dir} = 1;
        }
    }
}

Save this and run as root.

Good Luck!

Advertisements

From → Apple, Microsoft, Perl

4 Comments
  1. John permalink

    Thank you for this help. We re-installed Office (didn’t work for long) and then the entire operating system (didn’t work either) before we found your awesome fix. Something breaks these links even after reinstalling everything from scratch. You script saved the day and if thye break again we can just rerun it. You definitely “Rock!”

  2. Bryan permalink

    I am having a problem with the script. I get the following error:
    A unknown token can’t go after this “my”.

    The “my it is referring to is this one:
    # Office version
    my $version = 14;

Trackbacks & Pingbacks

  1. Microsoft Office Mac Suddenly Stops Working – FIX! | BigDiver

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: