I wanted to duplicate my active page in quantity to the first page. I used the code but it brings error "Object does not support this property or method"
Sub DuplicateToFirstPage()Dim sr As ShapeRange, nc As Integer, pnext As Page, sduplicate As Shapenc = InputBox("enter required")For i = 1 To ncSet sr = ActivePage.Shapes.AllSet pnext = ActiveDocument.InsertPages(1, False, ActiveDocument.Pages(1))For Each s In sr.ReverseRangeSet sduplicate = s.Duplicatesduplicate.MoveToLayer pnext.Layers(s.Layer.Name)Next sNext ipnext.Activate
End Sub
Another challenge is that, if there are no shapes in page "p" it should display the message box but it still went ahead to duplicate empty page
If ActiveDocument.Pages(p).Shapes.Count = 0 ThenMsgBox "No objects found on the selected page to duplicate"End If
Place Exit Sub after MsgBox
you mean like this?
If ActiveDocument.Pages(p).Shapes.Count = 0 ThenMsgBox "No objects found on the selected page to duplicate": Exit SubEnd If
yes. To halt execution of your sub
I've done it. It stopped the sub whether there is a shape or not