Column with information about the format size of a document

Getting the size of the first page/section is easier than I thought. Care to give this a try?

function OnInit(initData) {
    initData.name = 'WordPageSize';
    initData.version = '2022-12-14';
    initData.copyright = '';
    initData.url = 'https://resource.dopus.com/t/column-with-information-about-the-format-size-of-a-document/43135';
    initData.desc = '';
    initData.default_enable = true;
    initData.min_version = '12.0';
}

function OnAddColumns(addColData) {
    var col = addColData.AddColumn();
    col.name = 'WordPageSize';
    col.method = 'OnColumn';
}

var wordApp = new ActiveXObject('Word.Application');

function OnColumn(scriptColData) {
    if (wordApp == null) return;

    var item = scriptColData.item;
    if (item.is_dir) return;
    if (item.ext.substring(0, 4) != '.doc') return;
    if (item.name_stem.substring(0, 1) == '~') return;

    var wordDoc = wordApp.Documents.Open(String(item.realpath));

    var pageW = wordDoc.PageSetup.PageWidth;
    var pageH = wordDoc.PageSetup.PageHeight;
    
    pageW = Math.round(wordApp.PointsToMillimeters(pageW));
    pageH = Math.round(wordApp.PointsToMillimeters(pageH));
    
    wordDoc.Close();
    
    scriptColData.value = pageW + ' x ' + pageH;
}

ColumnWordPageSize.js.txt


1 Like