0

Does anyone have any idea why this is not working in publisher? There's very little documentation on it aside from msdn, and I can't figure it out. Every time I run it, it just says "Publisher Cannot link to this textbox".

Is there maybe some property I have to set to true first? Is that a common requirement in vba and other programming languages?

Option Compare Text

**Sub LinkTextBoxes()**
Dim shpTextBox1 As Shape
Dim shpTextBox2 As Shape

oAPIndex = ActiveDocument.ActiveView.ActivePage.PageIndex
Set shpTextBox1 = FindTB1(ActiveDocument.Pages(oAPIndex))
Set shpTextBox2 = FindTB1(ActiveDocument.Pages(oAPIndex + 1))

If shpTextBox1 Is Nothing Or shpTextBox2 Is Nothing Then
    MsgBox ("Textbox missing!" & vbLf & vbLf & "No can do!")
    Exit Sub
End If

shpTextBox1.TextFrame.NextLinkedTextFrame = shpTextBox2.TextFrame
ActiveDocument.ActiveView.ActivePage = ActiveDocument.Pages(oAPIndex + 1)
End Sub

**Function FindTB1(oPage As Page) As Shape**
Dim oShape As Shape
Dim oFoundShape As Shape

For Each oShape In oPage.Shapes
    If oShape.AlternativeText Like "*Text*" Then
        Set oFoundShape = oShape
        GoTo Found
    End If
Next

Found:
If oFoundShape Is Nothing Then
    MsgBox ("Text Box not found on page: " & oPage.PageNumber)
    Set FindTB1 = Nothing
Else
    Set FindTB1 = oFoundShape
End If
End Function

1 Answers1

0

Sorry guys, figured it out I think... Missed a line on msdn:

https://msdn.microsoft.com/en-us/library/office/ff940597.aspx

says it will be invalid if the shape already contains text.

Looks I might have to erase the text and repaste it or something similar first...