Closed lianyzhou closed 1 year ago
My Computer Environment:
win32 10.0.19044(x64) Windows 10 Home China 21H2 Windows Feature Experience Pack 120.2212.4190.0
nodejs version: v16.14.0 winax version: 3.3.4
console.log(doc.TablesOfContents[1]) and i found there's no UpdatePageNumbers function for word
Hi, doc.TablesOfContents is not array and similar doc.TablesOfContents.Item is not array, so you need to call Item as method: doc.TablesOfContents.Item(1).UpdatePageNumbers()
@durs Thanks a lot, doc.TablesOfContents.Item(1).UpdatePageNumbers() will work
First Thanks to Great job on creating node-activex,this makes more possibility for nodejs application.
Recently I encoutered a requirement of updating docx's table of contents,and I found node-activex.
Currently I cound did it by using WPS(https://www.wps.com/), but when using microsoft word, it report a error.
Here's my code ` var winax = require("winax"); var word; let doc = null; try { // word = new winax.Object("KWPS.Application"); word = new winax.Object("Word.Application"); doc = word.documents.open("E:/1.docx") doc.TablesOfContents[1].UpdatePageNumbers(); doc.save(); } catch(e) { console.log('encoutered exception', e); } finally { try { doc && doc.close(); } catch(e){ console.log('doc.close error'); }
} `
the word api i found here: https://learn.microsoft.com/zh-tw/dotnet/api/microsoft.office.interop.word.tableofcontents.updatepagenumbers?view=word-pia#microsoft-office-interop-word-tableofcontents-updatepagenumbers