×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

print preview sheet

print preview sheet

print preview sheet

(OP)
i use this:

CODE

Private Sub Command2_Click()

    If Me.ListView1.ListItems.Count >= 1 Then

        Screen.MousePointer = vbHourglass

        Me.Text1.SetFocus

        Me.LAZIONI.Caption = "STAMPA IN CORSO..."
        DoEvents

        Set excelWB = excelApp.Workbooks.Open(FILENAME:=STRPATH1 & WBNAME)
        Set excelWS = excelWB.Worksheets(SHNAME)

        FILENAME = Me.LTXT.Caption
        FNAME = Left(FILENAME, InStrRev(FILENAME, ".") - 1)
        excelWS.RANGE("A2").Value = "CODICE PROGRESSIVO: " & FNAME
        excelWS.RANGE("A3").Value = "CLIENTE: " & NOME
        excelWS.RANGE("A4").Value = "RICERCA: " & NOME
        excelWS.RANGE("E2").Value = "DATA INTERVENTO: " & DATA
        excelWS.RANGE("E3").Value = "INDIR: " & INDIRIZZO
        excelWS.RANGE("E4").Value = "CITTA': " & COMUNE
        excelWS.RANGE("I2").Value = "OPERATORE: " & DATO
        excelWS.RANGE("I3").Value = "CAP: " & CAP
        excelWS.RANGE("I4").Value = "PROVINCIA: " & "(" & PR & ") - " & PROVINCIA

        'FILL SHEET TEMPLATE
        'Call FILL_SHEET
        'FILL SHEET TEMPLATE

        With Printer
            .PaperSize = vbPRPSA4
        End With

        excelWB.Worksheets(SHNAME).PrintOut

        excelWB.Close savechanges:=False

        Set excelWB = Nothing
        Set excelWS = Nothing

        excelApp.Quit

        Me.LAZIONI.Caption = "TUTTO OK!"
        DoEvents
        Sleep (1500)
        Me.LAZIONI.Caption = ""

        Screen.MousePointer = vbDefault

    Else

        Beep
        Me.Text1.SetFocus
        Me.LAZIONI.Caption = "SELEZIONARE PRIMA UN FILE!"
        DoEvents
        Sleep (1500)
        Me.LAZIONI.Caption = ""

        Me.Text1.SetFocus

    End If

End Sub 

Before

excelWB.Worksheets(SHNAME).PrintOut

i nedd to printpreview the sheet, possible?

RE: print preview sheet

This is all documented, you know

excelWB.Worksheets(SHNAME).PrintOut Preview:=True


RE: print preview sheet

(OP)
Hi bro...
have error on your suggestion line of code.... see image.

here: excelWB.Worksheets(SHNAME).PrintOut Preview:=True

RE: print preview sheet

This message may be generated by the next line of the code, you switched workbook to preview mode and try to close it... So either automate printing as in your initial code or leave excel open in preview mode and let user close it.
A lot of printing customization can be set by code, without preview mode.
I doubt that it is possible to wait till user print the document. You can trap Workbook_BeforePrint event using WithEvents, AFAIK it fires in both print/print preview cases, except of cancelling printing it seems useless.

combo

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close