Results 1 to 3 of 3
  1. #1
    Lounger
    Join Date
    Jun 2009
    Location
    London, UK
    Posts
    42
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi,

    A lot of people associate macros with causing Word documents to become unstable, and I was wondering how true this is?

    I have a template that contains only the following macro (thanks Hans) -- would a simple macro like this cause any instability? Moreover, are templates/documents with lots of macros more likely to become unstable/corrupt?

    Many thanks,
    Sam

    Sub Renumber()
    **Dim i As Integer
    **With ActiveDocument.Sections(4).Headers(wdHeaderFooterP rimary).PageNumbers
    ****.RestartNumberingAtSection = True
    ****.StartingNumber = 1
    **End With
    **For i = 5 To ActiveDocument.Sections.Count
    ****With ActiveDocument.Sections(i).Headers(wdHeaderFooterP rimary).PageNumbers
    ******.RestartNumberingAtSection = False
    ****End With
    **Next i
    End Sub

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    In general, the more complex a document becomes, the larger the probability that the document gets corrupted. Macros contribute to the complexity of a document.
    But a relatively simple macro like this one is not very likely to corrupt the document.

  3. #3
    Super Moderator
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    3,852
    Thanks
    4
    Thanked 259 Times in 239 Posts
    Macros in themselves do not make a document more or less likely to become corrupt but as Hans says, the larger the document the more likelihood of corruption becoming an issue.

    However your code is not particularly bullet-proof so using that make macro on some documents will show an error when you run the code (but this should not be confused with a document corruption). For example, if your document doesn't have four sections then ActiveDocument.Sections(4) doesn't exist and so this line of code will error. You could modify the code to resolve the likely errors people will encounter
    Andrew Lockton, Chrysalis Design, Melbourne Australia

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •