Copy link to clipboard
Copied
1) How can I instantly alter the topics, after generating/updating a Word-document?
I tried this with no luck, see the results in my experiment.
2) How can I make sure that my ExtendScript is running only on the Word-Documents that 'Generate or Update'?
We will make projects with 20 or more linked Word-documents. So if one changes we won't run the script on all.
Experiment:
I have a script as following.
Searching all topics within a project => cleanup all inline styling/topic.
That works fine.
I registered the script as an event. (Event: postworddocupdate)
I assumed that this event would trigger from the moment a generate or an update, of a Word-document, has finished. Meaning the topics are made.
Why using this option:
We put multiple Word-documents in one project. We do this with a link, without making a copy of the Word-document.
I linked 2 Word-documents;
- Doc_A.docx
- Doc_B.docx
I 'Generate' the Word-document Doc_A.docx
Result in the 'Output View'
Number of Word-documents present: 2 => project.WordFileManager.count
name Word-document: Doc_A
name Word-document: Doc_B
Start removing inline styling ! => Start searching all topics within the project
Topic: Hello
Location: P:\Mdenbaes\RH_17\STK_N\Hello.htm => default topic
End removing inline styling ! => all topics within the project are handeld
Next:
I 'Generate' the Word-document Doc_B.docx
Result in the 'Output View'
Number of Word-documents present: 2
name Word-document: Doc_A
name Word-document: Doc_B
Start removing inline styling !
Topic: Sect steekkaart PC_124
Location: P:\Mdenbaes\RH_17\STK_N\File_A\Doc_A\Doc_A.htm => now the topic of the First Word-document is found.
Topic: Hello
Location: P:\Mdenbaes\RH_17\STK_N\Hello.htm
End removing inline styling !
As you can guess: If I 'Update' or 'Force update' one of the existing Word-documents: the topics of both Word-documents are shown in the 'Output View'.
Hi Marino,
The event delivers the full path of the word document that was updated as a parameter. From there, you can parse the linked word document XML to find the topics that are linked to the document. As you have probably found, ExtendScript offers various low level features, so more advanced stuf like this requires more work.
In my ExtendScript library I use the following code to get the linked files:
var Xpath = "//genfile/filename";
var loadFilesThatAreLinked = function(filepath) {
var Lin
...Copy link to clipboard
Copied
I don't have a solution for you - sorry - but I do a lot of linking to Word documents and the script you mention is interesting to me. Any chance you can post it in this thread?
Copy link to clipboard
Copied
It will not be possible to attach a script to a forum post. I suggest you use a Private Message to give your email address.
See www.grainge.org for RoboHelp and Authoring information
Copy link to clipboard
Copied
Thanks Peter - I sent a private message.
Copy link to clipboard
Copied
Hi Marino,
The event delivers the full path of the word document that was updated as a parameter. From there, you can parse the linked word document XML to find the topics that are linked to the document. As you have probably found, ExtendScript offers various low level features, so more advanced stuf like this requires more work.
In my ExtendScript library I use the following code to get the linked files:
var Xpath = "//genfile/filename";
var loadFilesThatAreLinked = function(filepath) {
var LinkedFiles = new Array();
var ContainerFile = new File(filepath);
if(ContainerFile.exists)
{
var ContainerXML = new XML(readFile(ContainerFile));
var LinkedFilesinContainer = ContainerXML.xpath(Xpath).children();
for(var i = 0; i< LinkedFilesinContainer.length();i++)
{
LinkedFiles.push(LinkedFilesinContainer.toString());
}
return LinkedFiles;
} else {
return null;
}
}
LinkedWordDocs = loadFilesThatAreLinked(projectpath()+WordContainer);
In here, I simply use an XPath to get all topics from a linked Word document, not from a specific Word document. This might be a good starting point. But you'll want to do it a little differently:
<word_doc>
<file_name>..\..\..\..\..\Desktop\Verduidelijking eis 6 Noordoostpolder.docx</file_name>
IF you want to get just the file name (if that's sufficient), use the filename() function from my library on the file path.