Results 1 to 11 of 11

Thread: VB Code to Print Landscape

  1. #1

    Thread Starter
    New Member
    Join Date
    Mar 2007
    Posts
    15

    Exclamation VB Code to Print Landscape

    Hi there,

    Does anyone know the VB 6 code for printing landscape.

    Have tried: but doesnt seem to work.

    cmdPrint.DefaultPageSettings.Landscape = True

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: VB Code to Print Landscape

    Is cmdPrint as command button? If so, there is no sub property as DeffaultPageSettings with a command button.

    In VB6, user the Printer Object, and you can set its Orientation method to landscape. Example:
    Code:
    Printer.FontName = "arial"
        Printer.FontUnderline = True
        Printer.FontSize = 8
        Printer.Orientation = vbPRORLandscape
    'etc

  3. #3

    Thread Starter
    New Member
    Join Date
    Mar 2007
    Posts
    15

    Re: VB Code to Print Landscape

    Quote Originally Posted by Hack
    Is cmdPrint as command button? If so, there is no sub property as DeffaultPageSettings with a command button.

    In VB6, user the Printer Object, and you can set its Orientation method to landscape. Example:
    Code:
    Printer.FontName = "arial"
        Printer.FontUnderline = True
        Printer.FontSize = 8
        Printer.Orientation = vbPRORLandscape
    'etc
    Hi there Hack,

    Yes it is a Command Button. I have Print in the Mnu, but i wanted the Quick Print Command button to print what i can see.

    See attached the .exe for my project.

    Jon
    Last edited by RobDog888; Mar 29th, 2007 at 12:22 AM. Reason: Removed exe zip attachment

  4. #4
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: VB Code to Print Landscape

    There is absolutely no way that I, or anyone else, is going to down load a zip file with nothing but an .Exe file in it.

    First off, I can't tell anything without looking at the source code, but far more importantly, I have no idea what that .exe does, and no intention of finding out.

    Attach your source code or post it.

  5. #5

    Thread Starter
    New Member
    Join Date
    Mar 2007
    Posts
    15

    Re: VB Code to Print Landscape

    Ok...fair enough...viruses and all that.

    See attached the form file
    Attached Files Attached Files

  6. #6
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: VB Code to Print Landscape

    I have seen this form before.

    Now, your original question was just how do you print landscape.

    What is it that you want to print. The Form itself? (very easy)

  7. #7

    Thread Starter
    New Member
    Join Date
    Mar 2007
    Posts
    15

    Re: VB Code to Print Landscape

    Yes the form....The Print in the Menu bit at the top is coded to do a VB Customised Print.

    What i want is that it shows the whole screen (as if it was a print screen on the program)

    Can you help??

  8. #8

    Thread Starter
    New Member
    Join Date
    Mar 2007
    Posts
    15

    Re: VB Code to Print Landscape

    Anybody???

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

    Re: VB Code to Print Landscape

    Exe attachment removed in post #3.

    To answer the first question: Tell the Printer object to print landscape.
    Printer.Orientation = vbPRORLandscape

    If you want to print a screenshot then you could use the keybd_event API to invoke the PrintScreen button and copy the screenshot to the clipboard. Then paste it into a hidden picturebox. Finally print the picturebox.
    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

  10. #10

    Thread Starter
    New Member
    Join Date
    Mar 2007
    Posts
    15

    Re: VB Code to Print Landscape

    Ok, how can i code that?? It looks pretty straight forward, but i am not that experienced.

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

    Re: VB Code to Print Landscape

    Here is the API definition. You can get it and allot of others if you download the api viewer utility (link in my signature).

    There are several code examples already on the forums if you need more.

    vb Code:
    1. Private Declare Sub keybd_event Lib "user32.dll" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
    2. 'And Const
    3. Private Const VK_SNAPSHOT As Long = &H2C
    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

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