Row Selection in InDesign done with VB

Humble Seeker

Member
Joined
Jun 18, 2003
Messages
10
Im using Visual Basic .Net to create an automated function for Adobe InDesign 2.0.2

The problem Im having is that I wish to select every cell in a row, except the first one, and then apply a specific font to it.

Source Code below:

Private Sub bulletChange(ByVal tableObject)
For Each Row In tableObject.Rows
If Row.Cells.Item(1).Texts.item(1).pointsize = 8 Then
For Each Cell In Row.Cells
a = l, b = m, c = l+
If Cell.Texts.item(1).TextContents.length < 3 And Cell.Texts.item(1).TextContents.length > 0 Then
Select Case Cell.Texts.item(1).TextContents
Case "l+"
Cell.Texts.item(1).TextContents = "c"
Case "l"
Cell.Texts.item(1).TextContents = "a"
Case "m"
Cell.Texts.item(1).TextContents = "b"
End Select
Cell.Texts.item(1).AppliedFont = mFont
End If
Next
End If
statusOfFormat.CurrentProgressBar.PerformStep()
Next
End Sub

Ive got this far. I can select the cells individually and apply the font, but its too slow for the purpose I need of it.

Anyone got any ideas how I can do this?

Thanks for taking the time to look.
 
I figured it out. I got it to work using the following code.

Private Sub bulletChange(ByVal tableObject)
Dim firstInstance As Integer = 0
Dim mySelection = mInDesign.Selection
Dim mTableCell

For Each Row In tableObject.Rows
If Row.Cells.Item(1).Texts.item(1).pointsize = 8 Then
For Each Cell In Row.Cells
a = l, b = m, c = l+
If Cell.Texts.item(1).TextContents.length < 3 And Cell.Texts.item(1).TextContents.length > 0 Then
Select Case Cell.Texts.item(1).TextContents
Case "l+"
Cell.Texts.item(1).TextContents = "c"
If firstInstance = 0 Then
firstInstance = Cell.index
End If
Case "l"
Cell.Texts.item(1).TextContents = "a"
If firstInstance = 0 Then
firstInstance = Cell.index
End If
Case "m"
Cell.Texts.item(1).TextContents = "b"
If firstInstance = 0 Then
firstInstance = Cell.index
End If
End Select
End If
Next
If firstInstance > 0 Then
mTableCell = tableObject.Cells.ItemByRange(tableObject.cells.item(firstInstance), tableObject.cells.item(Cell.index))
mInDesign.Selection = mTableCell
mySelection = mInDesign.Selection
mySelection.Item(1).VerticalJustification = InDesign.idVerticalJustification.idTop
mySelection.Item(1).texts.item(1).AppliedFont = mFont
firstInstance = 0
End If
End If
statusOfFormat.CurrentProgressBar.PerformStep()
Next
End Sub

Probably of no use to anyone else, but....
 
Back
Top