View Single Post
 
Old 09-08-2016, 04:41 AM
macropod's Avatar
macropod macropod is offline Windows 7 64bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,374
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Although the code could be improved, there is nothing obvious about it that would cause the errors you're experiencing. Given that the error message relates to fonts, perhaps you have a corrupt one in use by the document(s) throwing the error. Fixing that would entail identifying the font(s) used in that document that are not used elsewhere and reinstalling them.

As an example of the possible improvements, you could make the code more efficient by replacing:
Code:
Dim oSct As Section
Dim iSection As Integer
'
iSection = 1
'
For Each oSct In ActiveDocument.Sections
  With ActiveDocument.Sections(iSection).PageSetup
    .FirstPageTray = wdPrinterUpperBin
    .OtherPagesTray = wdPrinterMiddleBin
  End With
 
  iSection = iSection + 1
  '
Next oSct
with:
Code:
Dim oSct As Section
'
For Each oSct In ActiveDocument.Sections
  With oSct.PageSetup
    .FirstPageTray = wdPrinterUpperBin
    .OtherPagesTray = wdPrinterMiddleBin
  End With
Next oSct
If some of the documents have many Sections, you might use something like:
Code:
Dim iSection As Long
With ActiveDocument
  For iSection = 1 To .Sections.Count
    With .Sections(iSection).PageSetup
      .FirstPageTray = wdPrinterUpperBin
      .OtherPagesTray = wdPrinterMiddleBin
    End With
    If iSection Mod 20 = 0 Then DoEvents
  Next iSection
End With
Applying DoEvents periodically gives Word scope for its own housekeeping.

PS: When posting code, please use the code tags, indicated by the # button on the posting menu. Without them, your ~400 lines of code lost much of whatever structure it had.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote