Hi How can I using VBA move a Section of a Word Document. Regards D
Dim sCurSection As String sCurSection = Selection.Information(wdActiveEndSectionNumber) ActiveDocument.Sections(sCurSection).Range.Select will select the current section. Where do you want to move it to? -- <>>< ><<> ><<> <>>< ><<> <>>< <>><<> Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org <>>< ><<> ><<> <>>< ><<> <>>< <>><<> DMc2007 wrote: > Hi > > How can I using VBA move a Section of a Word Document. > > Regards > > D
Say if I have got ten sections in a document, i would want to move section 3 to before section 6. Regards D "Graham Mayor" wrote in message news:uS2WgGnDJHA.3636@TK2MSFTNGP02.phx.gbl... > Dim sCurSection As String > sCurSection = Selection.Information(wdActiveEndSectionNumber) > ActiveDocument.Sections(sCurSection).Range.Select > > will select the current section. Where do you want to move it to? > > -- > <>>< ><<> ><<> <>>< ><<> <>>< <>><<> > Graham Mayor - Word MVP > > My web site www.gmayor.com > Word MVP web site http://word.mvps.org > <>>< ><<> ><<> <>>< ><<> <>>< <>><<> > > > DMc2007 wrote: >> Hi >> >> How can I using VBA move a Section of a Word Document. >> >> Regards >> >> D > >
With ActiveDocument .Sections(3).Range.Cut .Sections(5).Range.Select With Selection .Collapse wdCollapseStart .Paste End With End With Note that when you have cut section 3, section 6 would then be section 5. When Section 3 is placed in its new position *it* will then be section 5 and Section 6 will again be Section 6 -- <>>< ><<> ><<> <>>< ><<> <>>< <>><<> Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org <>>< ><<> ><<> <>>< ><<> <>>< <>><<> DMc2007 wrote: > Say if I have got ten sections in a document, i would want to move > section 3 to before section 6. > > Regards > > D > > "Graham Mayor" wrote in message > news:uS2WgGnDJHA.3636@TK2MSFTNGP02.phx.gbl... >> Dim sCurSection As String >> sCurSection = Selection.Information(wdActiveEndSectionNumber) >> ActiveDocument.Sections(sCurSection).Range.Select >> >> will select the current section. Where do you want to move it to? >> >> -- >> <>>< ><<> ><<> <>>< ><<> <>>< <>><<> >> Graham Mayor - Word MVP >> >> My web site www.gmayor.com >> Word MVP web site http://word.mvps.org >> <>>< ><<> ><<> <>>< ><<> <>>< <>><<> >> >> >> DMc2007 wrote: >>> Hi >>> >>> How can I using VBA move a Section of a Word Document. >>> >>> Regards >>> >>> D