Results 1 to 2 of 2

Thread: Error repeating print process

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2009
    Posts
    5

    Error repeating print process

    Here's whan I want to be able to do
    From VB6 open an instance of word
    Open a word document already created
    Add a signature
    Print to a specificed printer
    Create a pdf file
    Delete the Original word doc
    Close word and repeat the process

    I have been able to complete the process but only once every time unless rerun the app, when I try to repeat the process error message "The remote server does not exist"

    This is my first ever post and I hope it makes sense, but can anybody help!!!

    My Code Is:
    I have a form called frmApproval

    Declerations are:
    Private WithEvents m_objWord As Word.Application
    Private WithEvents m_objDoc As Word.Document
    Dim m_cTemplate As String

    I have a list box with the available templates :
    Private Sub File1_DblClick()
    Call SelectPrinter
    cmdSave.Enabled = True
    m_cTemplate = (File1.path & "\" & File1.FileName)
    On Error Resume Next
    Set m_objWord = GetObject(, "Word.Application")
    On Error GoTo 0
    If m_objWord Is Nothing Then Set m_objWord = New Word.Application
    Set m_objDoc = m_objWord.Documents.Open(m_cTemplate, , False, True, , , , , , , , True)
    m_objWord.Visible = True
    End Sub


    I have a command button with a click event:
    Private Sub cmdSave_Click()
    Dim sCurrentPrinter, fn As String
    Dim flen As Integer
    Dim X As String
    flen = Len(File1.FileName)
    fn = Left(File1.FileName, flen - 4)
    sCurrentPrinter = Printer.DeviceName
    ActivePrinter = letprn
    m_objWord.ActiveDocument.PrintOut
    X = (adoPaths.Recordset.Fields!StoragePath & "\" & dep & "\Outgoing Approved ")
    ActivePrinter = "Adobe PDF"
    m_objWord.ActiveDocument.PrintOut True, False, , X & fn & ".ps", , , , , , , True
    Dim acr As New ACRODISTXLib.PdfDistiller
    acr.bShowWindow = False
    acr.FileToPDF X & fn & ".ps", X & fn & ".pdf", ""
    Kill (X & fn & ".ps")
    Kill (X & fn & ".log")
    Kill (m_cTemplate)
    File1.Refresh
    ActivePrinter = sCurrentPrinter
    m_objDoc.Close
    m_objWord.Quit
    Set m_objDoc = Nothing
    Set m_objWord = Nothing
    Me.Enabled = True
    End Sub

  2. #2
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: Error repeating print process

    Is ActivePrinter a variable/object in your project, or are you trying to refer to something that is Word based?

    If it is Word based you need to prefix it with an apt parent object, which might be like this:
    Code:
    m_objWord.ActivePrinter = letprn
    ..if that is the case, this change should fix the issue.


    Note that rather than using m_objWord.ActiveDocument , you should probably be using your m_objDoc variable (assuming that you intended to print that document, rather than whichever one happens to be active when that part of your code runs).

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