Opening MS Word
Posted: Thu Oct 14, 2021 6:22 pm
As part of my transition to MM5, I need to migrate some tools that I use to manage my collection. One such tool is a spellcheck that I developed. The good news in the code below is that it doesn't crash. The bad news is that it doesn't open Word. Any suggestions?
Code: Select all
// A simple script that checks the spelling of a Song Title
actions.SpellCheck = {
title: _('Spell Check'),
hotkeyAble: true,
disabled: uitools.notMediaListSelected,
visible: window.uitools.getCanEdit,
execute: async function () {
// Define variables
let list = uitools.getSelectedTracklist();
var objWord = new ActiveXObject("Word.Application");
objWord.visible = True;
objWord.options.autoFormatAsYouTypeReplaceQuotes = false;
var objDoc = objWord.documents.add;
//added count to give word a chance to catch up.
for(let intCnt = 1; intCnt <= 1000000; intCnt++) {
intCnt = intCnt + 1;
};
// Get list of selected tracks from MediaMonkey
list.forEach(lstItem => {
objDoc.activate;
objDoc.content.text = lstItem.title;
objDoc.CheckSpelling;
let str = objdoc.Content.Text
lstItem.title = str.substring(0, str.Length - 1);
});
// Write all back to DB and update tags
list.commitAsync();
objDoc.saved = false;
objDoc.close (0);
objDoc = null;
objWord.options.autoFormatAsYouTypeReplaceQuotes = true;
objWord.quit;
objWord = null;
alert("Spell Check is complete.");
}
}
window._menuItems.editTags.action.submenu.push({
action: actions.SpellCheck,
order: 40,
grouporder: 30
});