Excel-Word printing code

| | No TrackBacks

Excel-Word printing code

Private Sub CommandButton1_Click()
    Dim wks As Worksheet: Set wks = ThisWorkbook.ActiveSheet
    Dim app As New Word.Application
    Dim doc As Word.Document: Set doc = app.Documents.Add()
    app.Visible = True
    Call app.Activate
    Call app.ShowMe
    Dim rng As Word.Range: Set rng = doc.Range(Start:=0, End:=0)
    
    Dim i As Long: i = 1
    Dim CRLF As String: CRLF = Chr(13) & Chr(10)
    Dim s As String
    s = wks.Cells(i, 1) & " " & wks.Cells(i, 2) & CRLF
    s = s & wks.Cells(i, 3) & CRLF
    s = s & wks.Cells(i, 4) & ", " & wks.Cells(i, 5) & " " & wks.Cells(i, 6) & CRLF
    rng.Text = s
    rng.Font.Size = 36

    Call doc.PrintPreview
    Call doc.Close(SaveChanges:=False)
    Call app.Quit(SaveChanges:=False)
End Sub

No TrackBacks

TrackBack URL: http://www.iwebthereforeiam.com/cgi-bin/mt/mt-tb.cgi/72

Leave a comment

Verification (needed to reduce spam):

Pages

OpenID accepted here Learn more about OpenID
Powered by Movable Type 4.32-en

About this Entry

This page contains a single entry by Hugh Brown published on December 22, 2007 9:53 AM.

Flixxy videos was the previous entry in this blog.

All Along the Watchtower is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.