Results 1 to 8 of 8

Thread: Show page setup window

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2004
    Location
    Bloomingdale, IL USA
    Posts
    284

    Show page setup window

    Does anyone know how to get the page setup window to show in Excel VBA code? The people using the application want the ability to change the printer, and I can't figure out how to get the page setup window to show.

    Thanks!

  2. #2
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Show page setup window

    This should give you a starting point.
    VB Code:
    1. With ActiveSheet.PageSetup
    2.         .PrintTitleRows = ""
    3.         .PrintTitleColumns = ""
    4.     End With
    5.     ActiveSheet.PageSetup.PrintArea = ""
    6.     With ActiveSheet.PageSetup
    7.         .LeftHeader = ""
    8.         .CenterHeader = ""
    9.         .RightHeader = ""
    10.         .LeftFooter = ""
    11.         .CenterFooter = ""
    12.         .RightFooter = ""
    13.         .LeftMargin = Application.InchesToPoints(0.75)
    14.         .RightMargin = Application.InchesToPoints(0.75)
    15.         .TopMargin = Application.InchesToPoints(0.5)
    16.         .BottomMargin = Application.InchesToPoints(0.5)
    17.         .HeaderMargin = Application.InchesToPoints(0.5)
    18.         .FooterMargin = Application.InchesToPoints(0.5)
    19.         .PrintHeadings = False
    20.         .PrintGridlines = True
    21.         .PrintComments = xlPrintNoComments
    22.         .PrintQuality = 600
    23.         .CenterHorizontally = False
    24.         .CenterVertically = False
    25.         .Orientation = xlPortrait
    26.         .Draft = False
    27.         .PaperSize = xlPaperLetter
    28.         .FirstPageNumber = xlAutomatic
    29.         .Order = xlDownThenOver
    30.         .BlackAndWhite = False
    31.         .Zoom = 100
    32.         .PrintErrors = xlPrintErrorsDisplayed
    33.     End With
    When ever you want to know how something is done, usually you can get the code from recording a macro.
    Then in the VBA IDE you can look at the module of code that was generated to see what objects/methods/props
    were used.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2004
    Location
    Bloomingdale, IL USA
    Posts
    284

    Re: Show page setup window

    I don't want to set the parameters for them, I want the window to pop up and allow them to select the printer themselves.

  4. #4
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Show page setup window

    Oh, Ok here it is.
    VB Code:
    1. Dim oDlg As Dialog
    2.     Set oDlg = Application.Dialogs.Item(xlDialogPageSetup)
    3.     With oDlg
    4.         .Show
    5.     End With
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2004
    Location
    Bloomingdale, IL USA
    Posts
    284

    Re: Show page setup window

    Perfect! Thank you!!

  6. #6
    Addicted Member
    Join Date
    Jan 2005
    Posts
    138

    Re: Show page setup window

    Quote Originally Posted by RobDog888
    Oh, Ok here it is.
    VB Code:
    1. Dim oDlg As Dialog
    2.     Set oDlg = Application.Dialogs.Item(xlDialogPageSetup)
    3.     With oDlg
    4.         .Show
    5.     End With

    Very nice, I didn't know that!

  7. #7
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Show page setup window

    Thanks, actually code like this is faster then the code generated by a recorded macro.
    There is all kinds of things that you can do similar to this that you wouldnt even think you could do
    Like this one, you can preset the dialog to your desired settings and execute it without the dialog
    even being shown.

    I have been thinking of writting a FAQ but I haven't had much free time this month.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  8. #8
    Addicted Member
    Join Date
    Jan 2005
    Posts
    138

    Re: Show page setup window

    I would imagine!

    that would be very usefull no doubt!
    There must be a whole bunch of collections like you just used
    that I'm not even aware of.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width