Results 1 to 7 of 7

Thread: [RESOLVED]easy one - calling macro from another

Threaded View

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Apr 2005
    Posts
    103

    Resolved [RESOLVED]easy one - calling macro from another

    I'm writing a macro which goes through each shape, header and footer in a Word document individually and runs an external macro on it. This external macro was not written by me and I've no access to the code.

    So I have the macro loop through all the objects in question and call the macro with Run, but the whole thing seems to stop running after the Run statement, and the macro appears to run on the whole document, excluding the headers and footers. Should I be using something else rather than Run?

    VB Code:
    1. Sub CleanWholeDocument()
    2.  
    3. Dim sShape As Shape
    4. Dim fNote As Footnote
    5. Dim HeadFoot As HeaderFooter
    6. Dim sSection As Section
    7.  
    8. For Each sSection In ActiveDocument.Sections
    9.     For Each HeadFoot In sSection.Headers
    10.         HeadFoot.Range.Select
    11.         Application.Run MacroName:="tw4winClean.Main"
    12.     Next HeadFoot
    13. Next sSection
    14.  
    15. For Each fNote In ActiveDocument.Footnotes
    16.     fNote.Range.Select
    17.     Application.Run MacroName:="tw4winClean.Main"
    18. Next fNote
    19.  
    20. For Each sShape In ActiveDocument.Shapes
    21.     If sShape.TextFrame.HasText Then
    22.         sShape.TextFrame.TextRange.Select
    23.         Application.Run MacroName:="tw4winClean.Main"
    24.     End If
    25. Next sShape
    26.          
    27. Application.Run MacroName:="tw4winClean.Main"
    28.  
    29. End Sub
    Last edited by pickarooney; May 19th, 2005 at 06:01 AM.

Posting Permissions

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



Click Here to Expand Forum to Full Width