vbaoffice365publisher

How do you change the line spacing for selected text?


I have about 50 files done in Publisher 98 or 2000 that I am now opening in Publisher for Office 365.

All the textboxes that contain the font Comic Sans MS (about 40 in each file) need to have the line spacing changed from 1sp to 1.3sp to get it to flow the same way it did originally.

How do I change the line spacing once I have the text selected?

Sub fixPulications()
Dim PubApp As Application
Dim PubDocs As Documents
Dim PubDoc As Document
Dim MyDocs As Long
Dim MyDoc As Long
Dim PubPages As Pages
Dim PubPage As Page
Dim MyPages As Long
Dim MyPage As Long
Dim PubShapes As Shapes
Dim PubShape As Shape
Dim MyShapes As Long
Dim MyShape As Long
Dim MyFileName As String

   Set PubApp = Application
   Set PubDocs = Application.Documents
   Set PubDoc = Application.ActiveDocument
   Set PubPages = PubDoc.Pages

   MyDocs = PubDocs.Count
   MyDoc = 0
   MyPage = 0
   MyShape = 0

Do While MyDoc < MyDocs - 1
   Set PubDoc = Application.Documents(2)
   MyFileName = PubDoc.FullName
   MyPages = PubPages.Count
   
   Do While MyPage < MyPages
      MyPage = MyPage + 1
      Set PubPage = PubDoc.Pages(MyPage)
      MyShapes = PubShapes.Count
      
      Do While MyShape < MyShapes
         MyShape = MyShape + 1
         Set PubShape = PubPage.Shapes(MyShape)
         
         If PubShape.HasTextFrame Then
            If PubShape.TextFrame.TextRange.Font = "Comic Sans MS" Then
               With PubShape.TextFrame.TextRange.Story
' I can't figure out the correct syntax of the folowing line.
                  PubShape.TextFrame.TextRange.ParagraphFormat.LineSpacing (1.3) 
               End With
            End If
         End If
      Loop
      
      MyShape = 0
   Loop
   
   MyPage = 0
   MyDoc = MyDoc + 1
   PubDoc.SaveAs (MyFileName & "_R.pub")
   PubDoc.Close
Loop

End Sub

Solution

  • Try to set value as Publisher documentation recommends:

    ...    
    ...TextRange.ParagraphFormat.LineSpacing = 1.3 'not sure if non-integer value is valid
    ...