Results 1 to 6 of 6

Thread: [RESOLVED] [vb.net2k5] printing excel worksheet

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2007
    Posts
    617

    Resolved [RESOLVED] [vb.net2k5] printing excel worksheet

    ive seen other works but i was not able to follow there code sample. anyway i need a complete sample how to print excel worksheet in vb.net.

    thnx +rep.

  2. #2
    PowerPoster sparrow1's Avatar
    Join Date
    May 2005
    Location
    Globetrotter
    Posts
    2,820

    Re: [vb.net2k5] printing excel worksheet

    Hi,

    You can try this:

    vb Code:
    1. Globals.Sheet1.PrintOut(From:=1, To:=1, Copies:=2, Preview:=True)

    Hope it helps,

    sparrow1
    Wkr,
    sparrow1

    If I helped you, don't forget to Rate my post. Thank you

    I'm using Visual Studio.Net 2003 and
    2005
    How to learn VB.Net Create setup with VB 2005 Drawing for beginners VB.Net Tutorials GDI+ Tutorials
    Video's for beginners

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

    Re: [vb.net2k5] printing excel worksheet

    You can substiture the file to an Excel file but it works on just about all documents.

    From my FAQ

    http://www.vbforums.com/showpost.php...59&postcount=2
    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

  4. #4

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2007
    Posts
    617

    Re: [vb.net2k5] printing excel worksheet

    hi jack: code work perfect in my case.
    Code:
                With xlsTemplate
                    .Worksheets("sheet1").Cells(11, 10).Value() = ": " & _myemployee.refnum.ToString
                    .Worksheets("sheet1").Cells(14, 4).Value() = ": " & _myemployee.categoryid.ToString
                    .Worksheets("sheet1").Cells(15, 4).Value() = ": " & _myemployee.empno.ToString
                    .Worksheets("sheet1").Cells(16, 4).Value() = ": " & _myemployee.cprno.ToString
                    .Worksheets("sheet1").Cells(17, 4).Value() = ": " & _myemployee.fullname.ToString
                    .Worksheets("sheet1").Cells(18, 4).Value() = ": " & _myemployee.designation.ToString
                    .Worksheets("sheet1").Cells(19, 4).Value() = ": " & _myemployee.ccode.ToString
                    .Worksheets("sheet1").Cells(20, 4).Value() = ": " & _myemployee.designation.ToString
    
                    .Worksheets("Sheet1").PrintOut(From:=1, To:=1, Copies:=1, Preview:=False)
                End With
    hi rob. the printing works but the DATA i send to the excel sheet were not include in the printout.

    tnx +rep to both of you

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

    Re: [RESOLVED] [vb.net2k5] printing excel worksheet

    If you send the data to the xls then you need to save it too otherwise its just printing out the file as it was before you made your modifications.

    ps, wasnt sure if you were using the Excel Object Model or not.
    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

  6. #6

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2007
    Posts
    617

    Re: [RESOLVED] [vb.net2k5] printing excel worksheet

    hi rob. thnx for the info. anyway, im using excel object in the application.

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