Article View: adobe.scripting.indesign
Article #15378Re: Importing tagged text into InDesign
From: Mike_Mepham
Date: Mon, 01 Dec 2003 16:28
Date: Mon, 01 Dec 2003 16:28
75 lines
3008 bytes
3008 bytes
Hi Jodi,
Here are a couple of scripts in Word Basic that you can play with:
the first will convert Word tags into ID tags, but remember that ID will be expecting a header if you are importing the converted file into ID as tagged text.
Public Sub MAIN()
Dim tag$
WordBasic.StartOfDocument
While WordBasic.CmpBookmarks("\Sel", "\EndOfDoc")
'check that this not pre-tagged
If Selection.Characters(1) = "<" Then
GoTo skip
End If
If Selection.Text = vbCrLf Then
WordBasic.Insert "<ParaStyle:Blank line>"
GoTo skip
End If
Rem Get name for tag
tag$ = WordBasic.[StyleName$]()
Rem If style is "indent" remove bullet and tab
If UCase(tag$) = "INDENT" Then
WordBasic.CharRight 2, 1
WordBasic.EditCut
WordBasic.Insert "<ParaStyle:" + tag$ + ">"
Rem Insert tag if style is not "normal"
ElseIf (UCase(tag$) <> "NORMAL") Or (UCase(tag$) <> "PLAIN TEXT") Or (UCase(tag$) <> "Body Full Out") Then
WordBasic.Insert "<ParaStyle:Body Full Out>"
Else
WordBasic.Insert "<ParaStyle:Body Text>"
End If
skip:
WordBasic.Paradown
Wend
End Sub
The next will convert Ventura tags into Word Styles, this is the best bet for you as you only have to import the Word File and the styles will come with it.
Public Sub MAIN()
Dim WordStyle$
Dim FoundStyle$
Dim m
WordBasic.StartOfDocument
Rem Replace WordStyle$ with name of your Winword Template
Rem This should be enclosed in quotes, e.g. "mytempl"
WordBasic.FileTemplates Template:=WordStyle$
WordBasic.FormatStyle Merge:=1, FileName:=WordStyle$, Source:=1
While WordBasic.CmpBookmarks("\Sel", "\EndOfDoc")
Rem Look for @ at beginning of a tag
WordBasic.EditFind Find:="@", WholeWord:=0, MatchCase:=0, Direction:=0, Format:=0
If WordBasic.EditFindFound() Then
WordBasic.ExtendSelection "="
FoundStyle$ = WordBasic.[Selection$]()
m = Len(FoundStyle$)
m = m - 3
Rem Picks Winword style name from Ventura tag name
FoundStyle$ = Mid(FoundStyle$, 2, m)
WordBasic.CharRight 1, 1
Rem Deletes Ventura tag
WordBasic.EditCut
WordBasic.FormatStyle Name:=FoundStyle$, Apply:=1
Rem Adds bullets to "Indent" style
If UCase(FoundStyle$) = "INDENT" Then
WordBasic.ToolsBulletListDefault
End If
Else
WordBasic.EndOfDocument
End If
Wend
End Sub
Hope these help.
Mike
Technical Details
Message-ID:
<2cce9dd9.4@webx.la2eafNXanI>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!fu-berlin.de!newsfeed01.sul.t-online.de!t-online.de!webxReferences:
<2cce9dd9.-1@webx.la2eafNXanI>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f939a,a44852432b594c31 X-Google-Attributes: gidf939a,public X-Google-ArrivalTime: 2003-12-01 08:37:54 PST From: Mike_Mepham@adobeforums.com Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!fu-berlin.de!newsfeed01.sul.t-online.de!t-online.de!webx Newsgroups: adobe.scripting.indesign Subject: Re: Importing tagged text into InDesign Message-ID: <2cce9dd9.4@webx.la2eafNXanI> Date: Mon, 1 Dec 2003 08:28:12 -0800 References: <2cce9dd9.-1@webx.la2eafNXanI> Lines: 81 MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit