🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: adobe.scripting.indesign
Article #18936

Re: Question for Ole on style to tag mapping

#18936
From: pjredman
Date: Tue, 04 Feb 2003 20:03
93 lines
5449 bytes
Ole,

While looking over your script I came accross a line of code that made be realize what I had done wrong in my previous attempts. The problem relates to how text frames are referenced. I fixed up my original code and now it works with multiple stories. This is clearly a blunt instrument approach but it does what I need to do for now. I'm sure I will encorporate more of your script as I begin to understand it better.

Here's my current code:

Private Sub Command1_Click()
Dim myInDesign As InDesign.Application
Set myInDesign = CreateObject("InDesign.Application.2.0")
Set myDocument = myInDesign.ActiveDocument
For myStoryCount = 1 To myDocument.Stories.Count
    Set myStory = myDocument.Stories.Item(myStoryCount)
    Rem Set myTextFrame = myDocument.TextFrames.Item(myStoryCount)
    myXMLTag = "Story"
    Rem Set myXMLStory = myDocument.XMLElements.Add(myXMLTag, myTextFrame)
    Set myXMLStory = myDocument.XMLElements.Add(myXMLTag, myStory.TextFrames.Item(1))
        For myParaCount = 1 To myStory.Paragraphs.Count
            Set myPara = myStory.Paragraphs.Item(myParaCount)
            Select Case myPara.ParagraphStyle
                Case "Body Text"
                myXMLTag = "bodytext"
                Set myXMLPara = myXMLStory.XMLElements.Add(myXMLTag, myPara)
                Case "Heading 1"
                myXMLTag = "heading1"
                Set myXMLPara = myXMLStory.XMLElements.Add(myXMLTag, myPara)
                Case "Heading 2"
                myXMLTag = "heading2"
                Set myXMLPara = myXMLStory.XMLElements.Add(myXMLTag, myPara)
                Case "Reference"
                myXMLTag = "reference"
                Set myXMLPara = myXMLStory.XMLElements.Add(myXMLTag, myPara)
                Case "FigureCaption"
                myXMLTag = "figurecaption"
                Set myXMLPara = myXMLStory.XMLElements.Add(myXMLTag, myPara)
                Case "List Bullet"
                myXMLTag = "listbullet"
                Set myXMLPara = myXMLStory.XMLElements.Add(myXMLTag, myPara)
                Case "Table Title"
                myXMLTag = "tabletitle"
                Set myXMLPara = myXMLStory.XMLElements.Add(myXMLTag, myPara)
                Case "[No paragraph style]"
                myXMLTag = "undefined"
                Set myXMLPara = myXMLStory.XMLElements.Add(myXMLTag, myPara)
                Case "Title"
                myXMLTag = "title"
                Set myXMLPara = myXMLStory.XMLElements.Add(myXMLTag, myPara)
                Case "Heading 3"
                myXMLTag = "heading3"
                Set myXMLPara = myXMLStory.XMLElements.Add(myXMLTag, myPara)
                Case "Heading 4"
                myXMLTag = "heading4"
                Set myXMLPara = myXMLStory.XMLElements.Add(myXMLTag, myPara)
                Case "Heading 5"
                myXMLTag = "heading5"
                Set myXMLPara = myXMLStory.XMLElements.Add(myXMLTag, myPara)
                Case "Authors"
                myXMLTag = "authors"
                Set myXMLPara = myXMLStory.XMLElements.Add(myXMLTag, myPara)
                Case "SectionHeading"
                myXMLTag = "sectionheading"
                Set myXMLPara = myXMLStory.XMLElements.Add(myXMLTag, myPara)
                Case "BodyNoIndent"
                myXMLTag = "BodyNoIndent"
                Set myXMLPara = myXMLStory.XMLElements.Add(myXMLTag, myPara)
                Case "Colophon"
                myXMLTag = "colophon"
                Set myXMLPara = myXMLStory.XMLElements.Add(myXMLTag, myPara)
                Case "Footnote Text"
                myXMLTag = "footnotetext"
                Set myXMLPara = myXMLStory.XMLElements.Add(myXMLTag, myPara)
                Case "List Bullet 2"
                myXMLTag = "listbullet2"
                Set myXMLPara = myXMLStory.XMLElements.Add(myXMLTag, myPara)
                Case "List Bullet 3"
                myXMLTag = "listbullet3"
                Set myXMLPara = myXMLStory.XMLElements.Add(myXMLTag, myPara)
                Case "Outline"
                myXMLTag = "outline"
                Set myXMLPara = myXMLStory.XMLElements.Add(myXMLTag, myPara)
                Case "PhotoCredit"
                myXMLTag = "photocredit"
                Set myXMLPara = myXMLStory.XMLElements.Add(myXMLTag, myPara)
                Case "Quotation"
                myXMLTag = "quotation"
                Set myXMLPara = myXMLStory.XMLElements.Add(myXMLTag, myPara)
            End Select
        Next
Next
Beep
End Sub

Thanks again for the help,
Phil Redman
Technical Details
Message-ID: <1de7a030.7@WebX.la2eafNXanI>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-03!sn-xit-01!sn-xit-08!supernews.com!64.152.100.70.MISMATCH!sjc70.webusenet.com!news.webusenet.com!cyclone.bc.net!logbridge.uoregon.edu!xmission!nntp.infostrada.it!newsfeed01.sul.t-online.de!t-online.de!WebX
References: <1de7a030.-1@WebX.la2eafNXanI>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f939a,1f88565c9e628a0b
X-Google-Attributes: gidf939a,public
X-Google-ArrivalTime: 2003-02-04 12:07:47 PST
From: pjredman <pjredman@usgs.gov>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-03!sn-xit-01!sn-xit-08!supernews.com!64.152.100.70.MISMATCH!sjc70.webusenet.com!news.webusenet.com!cyclone.bc.net!logbridge.uoregon.edu!xmission!nntp.infostrada.it!newsfeed01.sul.t-online.de!t-online.de!WebX
Newsgroups: adobe.scripting.indesign
Subject: Re: Question for Ole on style to tag mapping
Message-ID: <1de7a030.7@WebX.la2eafNXanI>
Date: Tue, 4 Feb 2003 12:03:31 -0800
References: <1de7a030.-1@WebX.la2eafNXanI>
Lines: 122
MIME-Version: 1.0
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit