Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 01-24-2022, 09:23 PM
MaheshNandanikar MaheshNandanikar is offline Macro for page setup Windows 10 Macro for page setup Office 2016 for Mac
Novice
Macro for page setup
 
Join Date: Jul 2019
Posts: 1
MaheshNandanikar is on a distinguished road
Default Macro for page setup

I need to work on multiple files on a daily basis so I need a macro to run where it should ask me to select the page setup from the list that should popup when I run the macro and when I select the option it should apply that to the entire document below are required page steups that I want to include in macro.



1. 5.5x8.5"

2. 6x9"

3. 6.14x9.21"

4. 7X10"

5. 8.25X11"

I receive these documents from my publisher so I just want to change the page setup.
Reply With Quote
  #2  
Old 01-26-2022, 10:38 PM
Peterson Peterson is offline Macro for page setup Windows 10 Macro for page setup Office 2019
Competent Performer
 
Join Date: Jan 2017
Posts: 141
Peterson is on a distinguished road
Default

Try this:
Code:
Sub PageSize_SetVarious() ' 01/26/2022

    Dim strPageSize As String
    Dim strPageWidth As String, strPageHeight As String, strTopMargin As String, _
    strBottomMargin As String, strLeftMargin As String, strRightMargin As String, _
    strHeaderDistance As String, strFooterDistance As String
    
    ' Prompt user for page size:
    strPageSize = InputBox("Enter the page size you want (enter the numeral):" & _
    vbCrLf & vbCrLf & " 1.    5.5 x 8.5" & vbCrLf & " 2.    6 x 9" & _
    vbCrLf & " 3.    6.14 x 9.21" & vbCrLf & " 4.    7 x 10" & _
    vbCrLf & " 5.    8.25 x 11" & vbCrLf & _
    vbCrLf & "Specify Page Size:")

    ' If user cancels, exit sub:
    If strPageSize = vbNullString Then
        Exit Sub
    End If
    
    Select Case strPageSize
    
        ' Modify the margin and header/footer values to your needs.
        ' If you don't need to, delete these lines from each Case,
        ' and as noted below.
        Case 1 ' 5.5 x 8.5
            strPageWidth = "5.5"
            strPageHeight = "8.5"
            
            strTopMargin = "0.3"
            strBottomMargin = "0.3"
            strLeftMargin = "0.3"
            strRightMargin = "0.3"
            strHeaderDistance = "0.2"
            strFooterDistance = "0.2"
        Case 2 ' 6 x 9
            strPageWidth = "6"
            strPageHeight = "9"
            
            strTopMargin = "0.3"
            strBottomMargin = "0.3"
            strLeftMargin = "0.3"
            strRightMargin = "0.3"
            strHeaderDistance = "0.2"
            strFooterDistance = "0.2"
        Case 3 ' 6.14 x 9.21
            strPageWidth = "6.14"
            strPageHeight = "9.21"
            
            strTopMargin = "0.3"
            strBottomMargin = "0.3"
            strLeftMargin = "0.3"
            strRightMargin = "0.3"
            strHeaderDistance = "0.2"
            strFooterDistance = "0.2"
        Case 4 ' 7 x 10
            strPageWidth = "7"
            strPageHeight = "10"
            
            strTopMargin = "0.3"
            strBottomMargin = "0.3"
            strLeftMargin = "0.3"
            strRightMargin = "0.3"
            strHeaderDistance = "0.2"
            strFooterDistance = "0.2"
        Case 5 ' 8.25 x 11
            strPageWidth = "8.25"
            strPageHeight = "11"
            
            strTopMargin = "0.3"
            strBottomMargin = "0.3"
            strLeftMargin = "0.3"
            strRightMargin = "0.3"
            strHeaderDistance = "0.2"
            strFooterDistance = "0.2"
    End Select
        
    Selection.WholeStory
    
    ' If you don't need to set margins/headers/footers,
    ' then delete those lines below:
    With ActiveDocument.PageSetup
        .PageWidth = InchesToPoints(strPageWidth)
        .PageHeight = InchesToPoints(strPageHeight)
        
        .TopMargin = InchesToPoints(strTopMargin)
        .BottomMargin = InchesToPoints(strBottomMargin)
        .LeftMargin = InchesToPoints(strLeftMargin)
        .RightMargin = InchesToPoints(strRightMargin)
        .HeaderDistance = InchesToPoints(strHeaderDistance)
        .FooterDistance = InchesToPoints(strFooterDistance)
    End With
End Sub
Reply With Quote
Reply

Tags
vba code, word 16 page layout

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
documents print setup defined in page setup, but overriden by printer settings. macro required? Rosemary Word VBA 6 02-18-2021 11:10 PM
Macro for page setup Page setup before working luca155 PowerPoint 1 08-30-2012 12:06 PM
Page setup problem glenvern Word 1 09-19-2011 05:01 AM
Page Setup gus PowerPoint 0 03-09-2010 09:51 PM
Page Setup Ryan Word 0 01-24-2007 10:42 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 10:07 AM.


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