Question
Getting a CS2 Script to Work in CS4 VB
Hi,
The following script works for CS2. I am now trying to run it in CS4 but it
doesn't work. I have put the script in a folder within a folder called
"Version 2.0 Scripts" (inside the preexisting "Scripts Panel" folder).
Nevertheless, it doesn't work. Can anyone help me run this in CS4?
Rem BoxParagraphs.vbs
Rem An InDesign CS2 VBScript
Rem
Rem Converts all paragraphs of a given paragraph style
Rem to single-cell tables.
Set myInDesign = CreateObject("InDesign.Application.CS2")
Set myDocument = myInDesign.Documents.Item(1)
Set myStyle = myDocument.ParagraphStyles.Item("HRBox")
myInDesign.FindPreferences = idNothingEnum.idNothing
myInDesign.ChangePreferences = idNothingEnum.idNothing
myInDesign.FindPreferences.AppliedParagraphStyle = myStyle
Set myFoundItems = myDocument.Search()
myInDesign.FindPreferences = idNothingEnum.idNothing
If myFoundItems.Count <> 0 Then
For myCounter = myFoundItems.Count To 1 Step -1
Set myFoundItem = myFoundItems.Item(myCounter)
Set myStartCharacter = myFoundItem.Characters.Item(1)
Rem Special case for the last paragraph in a story.
Set myEndCharacter = myFoundItem.Characters.Item(-1)
If myEndCharacter.Contents = vbCr Then
Set myEndCharacter = myFoundItem.Characters.Item(-2)
End If
Rem Get the text of the paragraph, excluding the return character.
Set myText = myFoundItem.Texts.ItemByRange(myStartCharacter,
myEndCharacter)
Rem Convert the paragraph to a table.
Set myTable = myText.Item(1).ConvertToTable
Rem Adjust table properties here, if necessary.
Next
End If
Thank you,
Ariel
The following script works for CS2. I am now trying to run it in CS4 but it
doesn't work. I have put the script in a folder within a folder called
"Version 2.0 Scripts" (inside the preexisting "Scripts Panel" folder).
Nevertheless, it doesn't work. Can anyone help me run this in CS4?
Rem BoxParagraphs.vbs
Rem An InDesign CS2 VBScript
Rem
Rem Converts all paragraphs of a given paragraph style
Rem to single-cell tables.
Set myInDesign = CreateObject("InDesign.Application.CS2")
Set myDocument = myInDesign.Documents.Item(1)
Set myStyle = myDocument.ParagraphStyles.Item("HRBox")
myInDesign.FindPreferences = idNothingEnum.idNothing
myInDesign.ChangePreferences = idNothingEnum.idNothing
myInDesign.FindPreferences.AppliedParagraphStyle = myStyle
Set myFoundItems = myDocument.Search()
myInDesign.FindPreferences = idNothingEnum.idNothing
If myFoundItems.Count <> 0 Then
For myCounter = myFoundItems.Count To 1 Step -1
Set myFoundItem = myFoundItems.Item(myCounter)
Set myStartCharacter = myFoundItem.Characters.Item(1)
Rem Special case for the last paragraph in a story.
Set myEndCharacter = myFoundItem.Characters.Item(-1)
If myEndCharacter.Contents = vbCr Then
Set myEndCharacter = myFoundItem.Characters.Item(-2)
End If
Rem Get the text of the paragraph, excluding the return character.
Set myText = myFoundItem.Texts.ItemByRange(myStartCharacter,
myEndCharacter)
Rem Convert the paragraph to a table.
Set myTable = myText.Item(1).ConvertToTable
Rem Adjust table properties here, if necessary.
Next
End If
Thank you,
Ariel
