Results 1 to 13 of 13

Thread: [2008] Printing multiple Word documents

  1. #1

    Thread Starter
    Addicted Member Alexandru_mbm's Avatar
    Join Date
    Jul 2007
    Location
    VBForums.com
    Posts
    157

    [2008] Printing multiple Word documents

    There is a way for printing multiple Word document at once via VB.NET code ?
    I did not find any solution for this kind of job!

    Thanks in advice!
    I'm still learning VB.NET
    Sorry for my bad english
    Thanks for your help

  2. #2
    Pro Grammar chris128's Avatar
    Join Date
    Jun 2007
    Location
    England
    Posts
    7,604

    Re: [2008] Printing multiple Word documents

    You might be better off posting this in the Office section of these forums
    http://www.vbforums.com/forumdisplay.php?f=37

    But yeah, what code have you got so far? If you can print one document then you could just use some additional threads (either manually creating Threading.Thread instances or using the ThreadPool class) to do the same thing but for different documents. These threads could all run at the same time so should do what you want.
    My free .NET Windows API library (Version 2.2 Released 12/06/2011)

    Blog: cjwdev.wordpress.com
    Web: www.cjwdev.co.uk


  3. #3

    Thread Starter
    Addicted Member Alexandru_mbm's Avatar
    Join Date
    Jul 2007
    Location
    VBForums.com
    Posts
    157

    Re: [2008] Printing multiple Word documents

    Code:
            Dim WordApp As Microsoft.Office.Interop.Word.Application
            Dim MyDoc As String = frm_eliberare_cdm.cale_imprimare
            'init word object
            WordApp = New Microsoft.Office.Interop.Word.Application
    
            'show word
            WordApp.Application.Visible = True
    
            'open word file
            WordApp.Documents.Open(MyDoc)
    
            'printpreview
            WordApp.PrintPreview = True
    
            'print to printer
            'WordApp.PrintOut()
    this is my code so far....

    I think this code will blow up the computer!
    I'm still learning VB.NET
    Sorry for my bad english
    Thanks for your help

  4. #4
    Pro Grammar chris128's Avatar
    Join Date
    Jun 2007
    Location
    England
    Posts
    7,604

    Re: [2008] Printing multiple Word documents

    So what happens when you run that code?
    My free .NET Windows API library (Version 2.2 Released 12/06/2011)

    Blog: cjwdev.wordpress.com
    Web: www.cjwdev.co.uk


  5. #5

    Thread Starter
    Addicted Member Alexandru_mbm's Avatar
    Join Date
    Jul 2007
    Location
    VBForums.com
    Posts
    157

    Re: [2008] Printing multiple Word documents

    For a single document is not happening but if i have 100 or more the if i use
    "For each ..." statement will blow or not ?
    I'm still learning VB.NET
    Sorry for my bad english
    Thanks for your help

  6. #6
    Pro Grammar chris128's Avatar
    Join Date
    Jun 2007
    Location
    England
    Posts
    7,604

    Re: [2008] Printing multiple Word documents

    So it works fine for one document yes?
    My free .NET Windows API library (Version 2.2 Released 12/06/2011)

    Blog: cjwdev.wordpress.com
    Web: www.cjwdev.co.uk


  7. #7

    Thread Starter
    Addicted Member Alexandru_mbm's Avatar
    Join Date
    Jul 2007
    Location
    VBForums.com
    Posts
    157

    Re: [2008] Printing multiple Word documents

    Yes it works very well for a single document!

    But in my opinion it will not work as well for more than 5 documents... ?
    (for the app working on minimum PIII 800 MHz, 512 Mb RAM, XP, Word 2007)

    Isn't ?
    I'm still learning VB.NET
    Sorry for my bad english
    Thanks for your help

  8. #8
    Pro Grammar chris128's Avatar
    Join Date
    Jun 2007
    Location
    England
    Posts
    7,604

    Re: [2008] Printing multiple Word documents

    Well like I said, you could try using the ThreadPool class to create new thread objects that run this code. I dont know how well it would work though to be honest, as you could potentially end up with an awful lot of word.exe processes open... but do a bit of reading up on the ThreadPool class and background/multi -threading.
    http://msdn.microsoft.com/en-us/libr...threading.aspx
    My free .NET Windows API library (Version 2.2 Released 12/06/2011)

    Blog: cjwdev.wordpress.com
    Web: www.cjwdev.co.uk


  9. #9

    Thread Starter
    Addicted Member Alexandru_mbm's Avatar
    Join Date
    Jul 2007
    Location
    VBForums.com
    Posts
    157

    Re: [2008] Printing multiple Word documents

    OK! I'll try to do it like you said. I'll return on this post with some mori info! Thanks.
    I'm still learning VB.NET
    Sorry for my bad english
    Thanks for your help

  10. #10
    PowerPoster 2.0 Negative0's Avatar
    Join Date
    Jun 2000
    Location
    Southeastern MI
    Posts
    4,367

    Re: [2008] Printing multiple Word documents

    To save on performance, only create the word application once, and reuse it in the loop.

    The launching of Word is a fairly slow process, so if you only do that once, you will save a lot of time.

    One thing you need to be aware of with printing 100 documents like this is that each document is sent separately, so if users are using a network printer, there is nothing to stop someone else from printing a document in the middle of these 100 that are printing. With that many documents, one small document would probably get lost in the paper.

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

    Re: [2008] Printing multiple Word documents

    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

  12. #12

    Thread Starter
    Addicted Member Alexandru_mbm's Avatar
    Join Date
    Jul 2007
    Location
    VBForums.com
    Posts
    157

    Re: [2008] Printing multiple Word documents

    Quote Originally Posted by RobDog888
    This seems to be a quick code but give's me the error: "No application is associated with the specified file for this operation".

    The word file has now the extension ".mbm" but is associated with MS Word 2003.

    What can i do in this case ?!
    I'm still learning VB.NET
    Sorry for my bad english
    Thanks for your help

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

    Re: [2008] Printing multiple Word documents

    Start a process on "winword.exe" (include the path possiblly) and pass the complete filepath to the *.mbm file.
    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