Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 12-10-2023, 10:45 AM
nubuki nubuki is offline Loop through pages from cursor position to end of pages Windows 10 Loop through pages from cursor position to end of pages Office 2021
Novice
Loop through pages from cursor position to end of pages
 
Join Date: Dec 2023
Posts: 3
nubuki is on a distinguished road
Default Loop through pages from cursor position to end of pages

I'm trying to create a vba to loop through current page to the end of page and paste a copied shape on each of said pages.
I tried:

Code:
Sub PasteAndAlignItems()

    Dim totalPages As Integer

    Dim currentPage As Integer

    Dim startPosition As Range

    totalPages = ActiveDocument.BuiltInDocumentProperties(wdPropertyPages)

    Set startPosition = Selection.Range

    For currentPage = 1 To totalPages

        startPosition.Select

        Selection.PasteSpecial Placement:=wdInLine

        Selection.GoTo What:=wdGoToPage, Which:=wdGoToNext, Count:=1

    Next currentPage

End Sub
Works for text but not shapes; shapes get pasted on the same page with the cursor


Anyone knows what's wrong?
It would be very helpful if someone could add a snippet to position the pasted shape with horizontal alignment (left relative to page), vertical alignment (top relative to page).

Last edited by nubuki; 12-10-2023 at 10:47 AM. Reason: Grammatical fixes
Reply With Quote
 

Tags
macro, ms-word, vba



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to extract specific pages (Category) or arrange pages in a mail merge document? kitlwy Mail Merge 7 09-30-2021 04:50 AM
Loop through pages from cursor position to end of pages Number Pages - not total pages, but actual pages. Kiminator321 Word 8 04-29-2020 03:07 PM
Scroll through pages on loop ndearing Word VBA 5 12-17-2015 08:46 AM
Loop through pages from cursor position to end of pages Placing the same object/picture on all pages but on alternative (mirror position) - alceste Drawing and Graphics 1 09-29-2013 06:28 PM
Loop through pages from cursor position to end of pages create letter template with fixed position fields and follow up pages Lynn O'Shea Word 3 05-18-2010 12:32 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 01:50 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft