DEV Community

Oscar Sun(孫守真字任真)
Oscar Sun(孫守真字任真)

Posted on

Answer: Word VBA delete every page except the front page

So how about this?

Sub Word_VBA_delete_every_page_except_the_front_page()
    Dim d As Word.Document

    Dim rgePages As Range

    Rem no use here
    'Dim PageCount As Integer
    'PageCount = ActiveDocument.ComputeStatistics(wdStatisticPages)
    
    Set d = ActiveDocument: Set rgePages = d.Range '.Characters(1)
    
    Rem no use here
    'PageCount = d.ComputeStatistics(wdStatisticPages)
    
    'Selection.GoTo What:=wdGoToPage, Which:=wdGoToAbsolute, Count:=2
'    Set rgePages = Selection.Range

Top comments (0)