Table to text and format text
Learn / Forums / InDesign Add-ons (Scripts, Scripting, and Plug-ins) / Table to text and format text
- This topic has 1 reply, 2 voices, and was last updated 5 years, 10 months ago by Loic Aigon.
-
AuthorPosts
-
-
June 5, 2018 at 9:31 am #104207Elizabeth LockeMember
Help! I import XML with multiple tables. I don’t want the tables. I only want the text and I want that text formatted to a certain paragraph style.
I am new to scripting and I’m struggling to understand it. Google helped me find scripts for table to text. I added to the script to format the text to the paragraph style. The script works, but with an error message. I would like to use the script without the error message. (Now, the script isn’t working at all!)
Here’s the script:
var myDoc=app.activeDocument;
tableList = myDoc.textFrames.everyItem().tables.everyItem();
tableList.convertToText(“\t”,”\r”);
var myText = myTextFrame.parentStory.characters.everyItem();
myText.appliedParagraphStyle = myDoc.paragraphStyles.item(“[Price Section]”);Here’s the error message:
error 30476
the requested action could not be completed because the object no longer exists
engine: main
(script location)
Line: 3
Source: tableList.convertToText(“\t”,”\r”); -
June 5, 2018 at 2:53 pm #104209Loic AigonMember
Hi,
A possible option is to not use scripting but XSLT. You can then easily drop tables out and apply styles:
<pre class=”brush:xml”>
<?xml version=”1.0″ encoding=”UTF-8″?>
<xsl:stylesheet xmlns:xsl=”https://www.w3.org/1999/XSL/Transform”
xmlns:xs=”https://www.w3.org/2001/XMLSchema”
xmlns:aid=”https://ns.adobe.com/AdobeInDesign/4.0/”
xmlns:aid5=”https://ns.adobe.com/AdobeInDesign/5.0/”
exclude-result-prefixes=”xs”
version=”1.0″><xsl:output method=”xml” encoding=”UTF-8″/>
<xsl:template match=”Root”>
<Root xmlns:aid=”https://ns.adobe.com/AdobeInDesign/4.0/”
xmlns:aid5=”https://ns.adobe.com/AdobeInDesign/5.0/”
>
<xsl:apply-templates/>
</Root></xsl:template>
<xsl:template match=”node()|@*”>
<xsl:copy>
<xsl:apply-templates select=”node()|@*”/>
</xsl:copy>
</xsl:template><xsl:template match=”table”/>
<xsl:template match=”p” >
<xsl:copy>
<xsl:attribute name=”aid:pstyle”>[Price Section]</xsl:attribute>
<xsl:apply-templates select=”@*|node()”></xsl:apply-templates></xsl:copy>
</xsl:template>
</xsl:stylesheet>Then you can import and it’s all ok:
https://image.ibb.co/jEWVdT/Capture_d_e_cran_2018_06_05_a_23_52_49.png
-
-
AuthorPosts
- You must be logged in to reply to this topic.