简体   繁体   中英

Run macro until the end of the file in Visual Studio

Is there some AddIn or extension for Visual Studio 2008 that will allow me to run Macro until the end of the file? I really hate holding CTRL+SHIFT+P and waiting until end of the file is reached.

You could record a macro and then open the Macro IDE (Alt + F11) and place the prerecorded macro in a loop like this:

Sub TemporaryMacro()
    selection = DTE.ActiveDocument.Selection()
    anchorPoint = selection.AnchorPoint.CreateEditPoint
    selection.EndOfDocument(True)
    endPoint = selection.BottomPoint.CreateEditPoint()
    selection.MoveToPoint(anchorPoint)

    Do While True
        isEOF = DTE.ActiveDocument.Selection.TopPoint.CreateEditPoint().Line = endPoint.Line
        If (isEOF) Then
            Exit Do
        End If

        ' Prerecorded macro
        DTE.ActiveDocument.Selection.Text = " "
        DTE.ActiveDocument.Selection.LineDown()
        DTE.ActiveDocument.Selection.CharLeft()
        ' End of prerecorder macro

    Loop
End Sub

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM