Results 1 to 22 of 22

Thread: [RESOLVED] Display the File|Print Window

  1. #1

    Thread Starter
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,427

    Resolved [RESOLVED] Display the File|Print Window

    I would like to use VBA to go to what's shown in the picture. Is it possible? I've tried both Application.Dialogs(xlDialogPrint).Show and Application.Dialogs(xlDialogPageSetup).Show but neither one does what I want.
    Name:  Print.jpg
Views: 930
Size:  30.1 KB

  2. #2

  3. #3
    PowerPoster
    Join Date
    Oct 2010
    Posts
    2,141

    Re: Display the File|Print Window

    Try:
    Code:
    Application.CommandBars.FindControl(ID:=4).execute
    See this post for sources for the ID value. http://www.vbforums.com/showthread.p...=1#post4624945

  4. #4

  5. #5

    Thread Starter
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,427

    Re: Display the File|Print Window

    OMG Application.SendKeys "^{P}" doesn't work but Application.SendKeys "^{p}" does!

    I'll leave this open in the hope that there's a non-sendkeys option.

  6. #6
    PowerPoster
    Join Date
    Oct 2010
    Posts
    2,141

    Re: Display the File|Print Window

    Quote Originally Posted by MartinLiss View Post
    Unfortunately that gets me this.
    Name:  Windows_XP_-_Parallels_Desktop.jpg
Views: 872
Size:  141.1 KB
    Well I just learned a bit about the newer office versions that I do not have (still on 2007). The menu that you wish to access is call "Backstage view" and it appears to be an extension of the ribbon. Using the references I pointed to previously, there are these controls that include the word "Print" and are listed belonging to Backstage view.

    Control Name ID
    GroupPrintPreview 19140
    GroupPrintProtectedView 19094
    GroupPrintSettings 19139
    TabPrint 18244

    I would start with the "TabPrint" id first and try:
    Code:
    Application.CommandBars.FindControl(ID:=18244).Execute

  7. #7

  8. #8

  9. #9
    PowerPoster
    Join Date
    Oct 2010
    Posts
    2,141

    Re: Display the File|Print Window

    Quote Originally Posted by MartinLiss View Post
    Sorry, no, it's out-of-the-box Excel 2010.
    This is what I was writing about: http://www.excel-2010.com/backstage-...ft-excel-2010/

  10. #10

  11. #11
    PowerPoster
    Join Date
    Oct 2010
    Posts
    2,141

    Re: Display the File|Print Window

    Quote Originally Posted by MartinLiss View Post
    OK, you learn something new every day, but as I mentioned the code produces an error.
    Well it was worth a try. It looks like this probably will require code to access the ribbon. I have never done that, but I just found this article (with code) on how to control the ribbon. It is for controlling the ribbon in MS Word, but I would assume that the same techniques will work in Excel.

    No magic bullet, but it appears to be doable.

  12. #12
    New Member
    Join Date
    Jul 2014
    Posts
    3

    Re: Display the File|Print Window

    I found this in the Office Dev Center that may not show the window but changes the settings. Hopefully it can get you pointed in the right direction.

    Excel 2010: Communicate with PageSetup Using the Excel.PrintCommunication Method

    Also this on the office support page:

    Office Excel 2010 crashes when you programmatically print or print-preview a file

    I've seen the window referred to as "PrintPreview" and also "PageSetup" after snooping around.

    Correction: PageSetup is a different window but I think PrintPreview is correct.

    If you add a PrintPreviewAndPrint button to the QuickAccess tool bar, it gets you to that window directly so maybe you can find some hints by accessing that tool bar through TnTinMN's resource.
    Last edited by TakneItEasy; Jul 13th, 2014 at 02:41 AM.

  13. #13

    Thread Starter
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,427

    Re: Display the File|Print Window

    Thank you but that's similar to the code you can get if you record a macro while printing and it's not flexible. The SendKeys code takes me directly to the window and that's what I want to be able to do. If there's no other solution then I'm happy enough with that.

  14. #14
    New Member
    Join Date
    Jul 2014
    Posts
    3

    Re: Display the File|Print Window

    Good to know, I tried recording a macro but I'm on 2010 so it didn't show anything.

    BTW, with regards to using "^{P}" not working, I think sending capital letters is interpreted as adding a shift key.
    Last edited by TakneItEasy; Jul 14th, 2014 at 01:53 AM.

  15. #15

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

    Re: Display the File|Print Window

    Here you go Martin:

    Code:
    Application.CommandBars.ExecuteMso("PrintPreviewAndPrint")
    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

  17. #17

  18. #18

    Thread Starter
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,427

    Re: Display the File|Print Window

    Rob, while it works for Excel 2010, neither sendkeys nor your approach works in Excel 2007. Do you know a way to show the printpreview window in that version?

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

    Re: [RESOLVED] Display the File|Print Window

    I dont have 2007 at work but I believe this was new for Excel 2010.

    Edit: Yes for Excel its 2010+
    Last edited by RobDog888; Jul 15th, 2014 at 01:56 PM.
    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

  20. #20

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

    Re: [RESOLVED] Display the File|Print Window

    No prob. But you actually see the backstage view in Excel 07?

    http://books.google.com/books?id=qvz...202007&f=false
    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

  22. #22

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