Applying another Table format via script

Advocate ,
Mar 30, 2019

Copy link to clipboard

Copied

Looking for a way to change the table format (drop down list in the Table Designer) via scripting. Does anyone know what the Fcode for some 'Apply Table Format' command is? I have no idea what the command would be called like, so GetNamedCommand will not help me here. Should I use SetProps on the TblFormat instead? Has anyone done this before?

TOPICS
Scripting

Views

1.4K

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

1 Correct Answer

Enthusiast , Mar 30, 2019
Klaus Göbel Enthusiast , Mar 30, 2019
Hi Jang,here's a code snippet from Bharat Prakashfunction changeTblTag(active){            if(active.BookIsSelected || active.FirstSelectedComponentInBook)         iterateBook(active);    else if(active.ObjectValid())        {                        var flow = active.FirstFlowInDoc;                        while(flow.ObjectValid())                                {                            var i = 0;                            var textItems = flow.GetText(Constants.FTI_TblAnchor) // Get all tabl...

Likes

Translate

Translate
Jump to answer Jump to answer
Enthusiast ,
Mar 30, 2019

Copy link to clipboard

Copied

Hi Jang,

here's a code snippet from Bharat Prakash

function changeTblTag(active)

{

       

    if(active.BookIsSelected || active.FirstSelectedComponentInBook)

        iterateBook(active);

    else if(active.ObjectValid())

        {

                        var flow = active.FirstFlowInDoc;

                        while(flow.ObjectValid())       

                        {

                            var i = 0;

                            var textItems = flow.GetText(Constants.FTI_TblAnchor) // Get all tables in the flow

                           

                            var newtblfmt = active.GetNamedTblFmt(finalTag)

                            while(i<textItems.length)

                            {

                                if(isTableInReferenceOrHiddenPageOrMasterPage(textItems.obj.TextLoc))

                                    i++

                                else

                                {

                                    var currtblfmttag = textItems.obj.TblTag

                                    if(currtblfmttag == iniTag)

                                    {

                                        textItems.obj.SetProps (newtblfmt.GetProps())

                                        tblCount++

                                     }  

                                    i++

                                }

                               

                                if(i == textItems.length)

                                    break;

                            }

                        flow = flow.NextFlowInDoc

                        }

                      //       savedoc(active);  

          }

   

    if(DeleteFormat)

            iniTag.Delete()

}

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
4everJang AUTHOR LATEST
Advocate ,
Mar 30, 2019

Copy link to clipboard

Copied

Hello Klaus,

Thanks for digging this up. It is a lot of code I don't need, but the one vital line solved my problem. Getting the properties of the named table format and applying all those properties to the table object makes sense. And it works.

Ciao

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more