|
-
Apr 21st, 2005, 01:50 PM
#1
Thread Starter
Hyperactive Member
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!
-
Apr 21st, 2005, 01:56 PM
#2
Re: Show page setup window
This should give you a starting point.
VB Code:
With ActiveSheet.PageSetup
.PrintTitleRows = ""
.PrintTitleColumns = ""
End With
ActiveSheet.PageSetup.PrintArea = ""
With ActiveSheet.PageSetup
.LeftHeader = ""
.CenterHeader = ""
.RightHeader = ""
.LeftFooter = ""
.CenterFooter = ""
.RightFooter = ""
.LeftMargin = Application.InchesToPoints(0.75)
.RightMargin = Application.InchesToPoints(0.75)
.TopMargin = Application.InchesToPoints(0.5)
.BottomMargin = Application.InchesToPoints(0.5)
.HeaderMargin = Application.InchesToPoints(0.5)
.FooterMargin = Application.InchesToPoints(0.5)
.PrintHeadings = False
.PrintGridlines = True
.PrintComments = xlPrintNoComments
.PrintQuality = 600
.CenterHorizontally = False
.CenterVertically = False
.Orientation = xlPortrait
.Draft = False
.PaperSize = xlPaperLetter
.FirstPageNumber = xlAutomatic
.Order = xlDownThenOver
.BlackAndWhite = False
.Zoom = 100
.PrintErrors = xlPrintErrorsDisplayed
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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 
-
Apr 21st, 2005, 02:00 PM
#3
Thread Starter
Hyperactive Member
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.
-
Apr 21st, 2005, 02:07 PM
#4
Re: Show page setup window
Oh, Ok here it is.
VB Code:
Dim oDlg As Dialog
Set oDlg = Application.Dialogs.Item(xlDialogPageSetup)
With oDlg
.Show
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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 
-
Apr 21st, 2005, 02:58 PM
#5
Thread Starter
Hyperactive Member
Re: Show page setup window
-
Apr 21st, 2005, 11:57 PM
#6
Addicted Member
Re: Show page setup window
 Originally Posted by RobDog888
Oh, Ok here it is.
VB Code:
Dim oDlg As Dialog
Set oDlg = Application.Dialogs.Item(xlDialogPageSetup)
With oDlg
.Show
End With

Very nice, I didn't know that!
-
Apr 22nd, 2005, 12:10 AM
#7
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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 
-
Apr 22nd, 2005, 12:20 AM
#8
Addicted Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|