• Bit of code for Word 2016 for Mac stopped working

    Home » Forums » AskWoody support » Productivity software by function » Visual Basic for Applications » Bit of code for Word 2016 for Mac stopped working

    Author
    Topic
    #1773570

    With the last update I had some code that doesn’t work any more on a Mac using Word 2016 with the newest OS:

    This is the bit:

    Rem *** Remove common direct character level formatting to prevent passthrough ***
    Private Sub ResetTextToBase()
    Dim MyStyle As Style
    Dim MyParagraph As Paragraph
    Home
    For Each MyParagraph In ActiveDocument.Paragraphs
    BText “Cleaning up direct formatting in text”
    MyParagraph.Range.Select
    If Not Selection.Information(wdWithInTable) Then
    Set MyStyle = Selection.Style
    With Selection
    .Font.Name = MyStyle.Font.Name
    .Font.Size = MyStyle.Font.Size
    End With
    End If
    Next MyParagraph
    Set MyStyle = Nothing
    Set MyParagraph = Nothing
    End Sub

    What it does is to take paragraphs that have been passed between several authors and remove all of the garbage that each one introduces while preserving italics and caps and small caps. The error occurs on the line (run-time error 91):

    .Font.Name = MyStyle.Font.Name

    I’ve know this bit of code needed some updating for a while because it’s a pretty old routine. I appreciate any help you can give me.

    Thanks!

    Reply To: Bit of code for Word 2016 for Mac stopped working

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: