Results 1 to 5 of 5
  1. #1
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    send doc before to print... (2000 sr-1)

    In a useform have this part of code...
    How to send via e-mail the doc in object before to print and close it?

    'stampa Pegno su 1745/3BF
    '
    Set MODULO = CreateObject("WORD.APPLICATION")
    MODULO.Visible = False
    MODULO.Documents.Open Filename:=Sheets("CARTELLE DI LAVORO").Range("A2") & "1745-3 BF.doc"
    '

    MODULO.ActiveDocument.FormFields(1).result = agenzia
    MODULO.ActiveDocument.FormFields(5).result = fido1 & " " & divfido1 & " " & impfido1
    MODULO.ActiveDocument.FormFields(6).result = fido2 & " " & divfido2 & " " & impfido2
    MODULO.ActiveDocument.FormFields(7).result = fido3 & " " & divfido3 & " " & impfido3
    MODULO.ActiveDocument.FormFields(8).result = fido4 & " " & divfido4 & " " & impfido4
    MODULO.ActiveDocument.FormFields(9).result = fido5 & " " & divfido5 & " " & impfido5
    MODULO.ActiveDocument.FormFields(10).result = fido6 & " " & divfido6 & " " & impfido6

    MODULO.ActiveDocument.FormFields(11).result = "EURO " & totimp
    If Not totimplettere = "" Then MODULO.ActiveDocument.FormFields(12).result = "EURO " & totimplettere

    MODULO.ActiveDocument.FormFields(13).result = Variabile1
    MODULO.ActiveDocument.FormFields(14).result = affidato

    MODULO.ActiveDocument.FormFields(15).result = garante1
    MODULO.ActiveDocument.FormFields(16).result = garante2
    MODULO.ActiveDocument.FormFields(17).result = garante3
    MODULO.ActiveDocument.FormFields(18).result = garante4
    MODULO.ActiveDocument.FormFields(19).result = garante5
    '
    MODULO.ActiveDocument.FormFields(20).result = garante1
    MODULO.ActiveDocument.FormFields(21).result = garante2
    MODULO.ActiveDocument.FormFields(22).result = garante3
    MODULO.ActiveDocument.FormFields(23).result = garante4
    MODULO.ActiveDocument.FormFields(24).result = garante5
    '
    STAMPANTEPREDEFINITA = MODULO.ActivePrinter
    STAMPANTEMODULO = UserForm1.stampante.Caption
    MODULO.ActivePrinter = STAMPANTEMODULO
    MODULO.ActiveDocument.PrintOut , Background:=False
    MODULO.ActivePrinter = STAMPANTEPREDEFINITA
    MODULO.Quit wdDoNotSaveChanges
    '
    'stampa dichiarazione allegata
    '

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: send doc before to print... (2000 sr-1)

    You can use MODULO.Activedocument.SendMail to display an e-mail with the document as attachment. But you will have to enter the e-mail address etc. yourself.

  3. #3
    WS Lounge VIP sdckapr's Avatar
    Join Date
    Jul 2002
    Location
    Pittsburgh, Pennsylvania, USA
    Posts
    11,225
    Thanks
    14
    Thanked 342 Times in 335 Posts

    Re: send doc before to print... (2000 sr-1)

    Does the article on Send an email from Word help?

    Note: All your code is from WORD VBA not excel VBA. Even if it is called originally from excel, it is not using excel VBA. You may want to post any additional questions on this part of your code in the WORD forum...

    Steve

  4. #4
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: send doc before to print... (2000 sr-1)

    Sorry for big code.....
    I dont understand why when the code go in Private Sub stampaproposta_Click, line:
    MODULO.Documents.Open Filename:=Sheets("CARTELLE DI LAVORO").Range("A2") & "1727-1.doc"
    Have message "file alreday opened from other user"
    Note:
    Have dimensioned in other module the var MODULO:
    Global MODULO As Object

  5. #5
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: send doc before to print... (2000 sr-1)

    The message means exactly what it says: the document is still open. Make sure that the document has been closed before you run this code, and that there is no file whose name resembles that of the document but beginning with ~$.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •