Results 1 to 3 of 3

Thread: Printing in VB6

Threaded View

  1. #1

    Thread Starter
    Addicted Member waelr's Avatar
    Join Date
    Nov 2004
    Posts
    168

    Printing in VB6

    hey guys im using the following code to print contents of a flexgrid and some textboxes
    im exporting the data to an excel file and then printing it
    VB Code:
    1. Set xlApp = CreateObject("Excel.Application")
    2.     Set xlBook = xlApp.Workbooks.Add
    3.     Set xlSheet = xlBook.Worksheets(1)
    4.     xlBook.Worksheets(3).Delete
    5.     xlBook.Worksheets(2).Delete
    6.    
    7.     With xlSheet
    8.             .PageSetup.Orientation = 2
    9.             .PageSetup.LeftMargin = 0
    10.             .PageSetup.TopMargin = 0
    11.             .Cells.WrapText = False
    12.             .Cells.Font.Size = 8
    13.            
    14.             Dim dt
    15.             dt = Date
    16.             .Range("A1").ColumnWidth = 3
    17.             .Range("B1").ColumnWidth = 13
    18.             .Range("C1").ColumnWidth = 6
    19.             .Range("B1").Value = dt
    20.             .Range("A2").Value = "Name"
    21.             .Range("A2").Font.Name = "Monotype Corsiva"
    22.             .Range("A2").Font.Size = 14
    23.             .Range("A3").Value = "Address1"
    24.             .Range("A3").Font.Bold = True
    25.             .Range("A4").Value = "Address2"
    26.             .Range("A4").Font.Bold = True
    27.             .Range("A5").Value = "Phone Number"
    28.             .Range("A5").Font.Bold = True
    29.            
    30.             .Range("A6").Value = "Cashier: " & FormStart.Text1
    31.             .Range("A6").Font.Bold = True
    32.            
    33.             .Range("A7").Value = "Invoice #: " & Text4
    34.             .Range("A7").Font.Bold = True
    35.             .Range("A8").Value = Combo1.Text
    36.             .Range("A8").Font.Bold = True
    37.            
    38.             .Range("A9").Value = "----------------------------------------"
    39.             .Range("A10").Value = "Qty"
    40.             .Range("A10").Font.Bold = True
    41.             .Range("B10").Value = "Item"
    42.             .Range("B10").Font.Bold = True
    43.             .Range("C10").Value = "Price"
    44.             .Range("C10").Font.Bold = True
    45.             .Range("A11").Value = "----------------------------------------"
    46.            
    47.             For i = 1 To MSF.Rows - 1
    48.                 For j = 1 To 3
    49.                 xlSheet.Cells(11 + i, j) = MSF.TextMatrix(i, j - 1)
    50.                 Next j
    51.             Next i
    52.             k = 11 + i
    53.             .Range("A" & k).Value = "Discount"
    54.             .Range("A" & k).Font.Bold = True
    55.             .Range("C" & k).Value = Text2 & " %"
    56.             k = k + 2
    57.             .Range("B" & k).Value = "TOTAL " & Text1 & " $"
    58.             .Range("B" & k).Font.Size = 12
    59.             .Range("B" & k).Font.Bold = True
    60.  
    61.     End With
    62.  
    63.     xlApp.Visible = False
    64.  
    65.     'xlSheet.PrintOut (1)
    66.     Dim y
    67.     y = "Sample.xls"
    68.     xlSheet.SaveAs (y)
    69.     xlApp.Workbooks.Close


    I attached the "Sample.xls" file
    how can i get the same result using the VB6 Data Report or Crystal Reports 9
    Attached Files Attached Files

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