how to print multiple word documents via vb.net

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • SpamProof

    how to print multiple word documents via vb.net

    I'd like to be able to print multiple documents are once using vb.net.
    What is the best way to do this with out having to print each document
    one at a time via a loop [calling
    Word.PrintOut(f ileName:=(Outpu tFileLocation & fileName)].

    Can't I send them all to a spool at once or something?

    Ideally, I would like the code such that multiple users can print via
    my application at the same time.

    Any help would be appreciated. Thanks

    8957078

    PS

    Someone suggested merging the docs into one programatically but i'm
    not sure if that would solve the problem i'm having with the printing
    getting locked up when users try to print at the same time.

    If this is a good idea, does anyone have any examples?
  • Fergus Cooney

    #2
    Re: how to print multiple word documents via vb.net

    Hi 8957078,

    Unusual handle you've got there! ;-)

    I think <your program> is going to have to be that spooler.

    What's the objection to looping through your Word.Prints? If it's because
    your app can't do anything until all the printing is done, then I would
    suggest learning just how easy** it can be to do it in a separate Thread.

    When you say 'multiple users ... at the same time', what do you mean,
    exactly?

    Regards,
    Fergus

    ** 'easy' - a relative term, but I would hope that you'd be nicely surprised.
    :-)


    Comment

    • SpamProof

      #3
      Re: how to print multiple word documents via vb.net

      Below is my code. The object I loop through is an array of documents
      data (holds paths and filenames of docs to be printed).

      I'm using InterOp. It seems to lock up and never print if two or more
      users try to print the same documents.

      In any case, do you have an example of doing the multi thread for this
      situation?


      Thanks for your input.

      8957078


      ----------------------------------------------------------------
      Try
      MergeDocumentAn dPrint(document s, aDocumentInform ation)

      ''Original Code Below
      'If Not documents Is Nothing AndAlso documents.Count > 0
      Then
      ' m_Word = CreateObject("W ord.Application ")
      'Start Word and open the document template.
      ' m_Word.Visible = False
      'Have Word run in background

      ' We have some files, Print Them
      For Each aDocumentInform ation In documents
      If Not
      aDocumentInform ation.Endorseme ntLongDescripti on = (New
      BOConstants).QU OTE_SHEET_NAME Then

      Me.PrintDocumen t(aDocumentInfo rmation.FileNam e)
      End If
      Next
      Me.CloseWinWord () 'Clean Up
      End If
      Catch ex As Exception
      Me.CloseWinWord ()
      Me.CreatePrinti ngException("Th e following error received
      while attempting to print a document: " & _
      ex.ToString)
      End Try
      ----------------------------------------------------------------

      "Fergus Cooney" <filter-1@tesco.net> wrote in message news:<#eG#50mkD HA.2328@TK2MSFT NGP10.phx.gbl>. ..[color=blue]
      > Hi 8957078,
      >
      > Unusual handle you've got there! ;-)
      >
      > I think <your program> is going to have to be that spooler.
      >
      > What's the objection to looping through your Word.Prints? If it's because
      > your app can't do anything until all the printing is done, then I would
      > suggest learning just how easy** it can be to do it in a separate Thread.
      >
      > When you say 'multiple users ... at the same time', what do you mean,
      > exactly?
      >
      > Regards,
      > Fergus
      >
      > ** 'easy' - a relative term, but I would hope that you'd be nicely surprised.
      > :-)[/color]

      Comment

      • Cindy M  -WordMVP-

        #4
        Re: how to print multiple word documents via vb.net

        Hi SpamProof,
        [color=blue]
        > I'm using InterOp. It seems to lock up and never print if two or more
        > users try to print the same documents.
        >[/color]
        The problem you're running into is inherent to Word: Word puts a file
        lock on opened documents because it doesn't support any kind of file
        sharing.

        My suggestion would be to have your program create a COPY of the
        document (at the file level), open that, print it. And when the print
        process is finished, delete all the copies.

        -- Cindy

        Comment

        Working...