+ Reply to Thread
Results 1 to 4 of 4

Adding grid lines and line numbers in the report

Hybrid View

aman1234 Adding grid lines and line... 03-04-2014, 10:49 AM
nathansav Re: Adding grid lines and... 03-04-2014, 11:49 AM
aman1234 Re: Adding grid lines and... 03-05-2014, 05:09 AM
aman1234 Re: Adding grid lines and... 03-05-2014, 05:31 AM
  1. #1
    Forum Contributor
    Join Date
    02-20-2009
    Location
    bristol
    MS-Off Ver
    Excel 2003
    Posts
    882

    Adding grid lines and line numbers in the report

    Hi guys

    Please see the code below. It works fine but in the report that gets printed off, it doesn't display grid lines and line numbers . Can it be done?

    Please can anyone help me in this?

    
    Private Sub CommandButton1_Click()
    Dim cn As ADODB.Connection
      Dim rs As ADODB.Recordset
      Dim r As Long
        ' connect to the Access database
      Set cn = New ADODB.Connection
      cn.Open "Provider=Microsoft.Jet.OLEDB.4.0; " & _
            "Data Source=J:\System1.mdb;"
            
      Set rs = New ADODB.Recordset
    Dim wb As Workbook
    Dim ws As Worksheet
    Set wb = ActiveWorkbook
    Dim J As Integer
         Dim i As Integer
         Dim a As Date
         Dim t As Date
    
    strsql = "select BatchNo,PolicyNo,CustInitial as [customer Initial],custSurname as [Customer Surname],BarcodeRef,DocumentType,DocumentProvenance,Status from tblmain where InputDate>= #" & Format(DateSerial(ComboBox3, ComboBox2, ComboBox1), "mm/dd/yyyy") & "# and Inputdate <= #" & Format(DateSerial(ComboBox6, ComboBox5, ComboBox4), "mm/dd/yyyy") & "# and Status='Retain and send to PWR'"
       rs.Open strsql, cn
      Set ws = ThisWorkbook.Worksheets("sheet1")
            For colIndex = 0 To rs.Fields.Count - 1
            ws.Cells(1, colIndex + 1) = rs.Fields(colIndex).Name
            Next
         
        ws.Cells(2, 1).CopyFromRecordset rs
        ws.Rows(1).Font.Bold = True
         
         
            ws.UsedRange.Columns.AutoFit
           
            With ws.PageSetup
           ' .LeftHeader = "&""Arial""&10" & "Date: " & Format(DateSerial(ComboBox3, ComboBox2, ComboBox1), "dd/mm/yyyy")
           .CenterHeader = "&""Arial,Bold""&14" & b & " MI Report from " & a & " to " & t
           .Orientation = xlLandscape
           
            .Zoom = False
            .FitToPagesWide = 1
            
          '  .FitToPagesTall = 1
        End With
         Answer = MsgBox("Do you want to print this report?", vbQuestion + vbYesNo + vbDefaultButton2)
        If Answer = vbYes Then
        
        ws.PrintOut
        MsgBox "The report has been printed"
        End If
         
         rs.Close
         cn.Close
         
        Set rs = Nothing
        Set cn = Nothing
    End Sub

  2. #2
    Valued Forum Contributor
    Join Date
    09-21-2011
    Location
    Birmingham UK
    MS-Off Ver
    Excel 2003/7/10
    Posts
    2,188

    Re: Adding grid lines and line numbers in the report

    .PrintHeadings = True
    .PrintGridlines = True
    Hope this helps

    Sometimes its best to start at the beginning and learn VBA & Excel.

    Please dont ask me to do your work for you, I learnt from Reading books, Recording, F1 and Google and like having all of this knowledge in my head for the next time i wish to do it, or wish to tweak it.
    Available for remote consultancy work PM me

  3. #3
    Forum Contributor
    Join Date
    02-20-2009
    Location
    bristol
    MS-Off Ver
    Excel 2003
    Posts
    882

    Re: Adding grid lines and line numbers in the report

    Thats doesn't work. Please can anyone help me in this?

    Many thanks

  4. #4
    Forum Contributor
    Join Date
    02-20-2009
    Location
    bristol
    MS-Off Ver
    Excel 2003
    Posts
    882

    Re: Adding grid lines and line numbers in the report

    Thanks nathansav. It actually worked. SO now the gridlines are appearing in the print report. Now I want to display row numbers (lines numbers) too in the report.

    How can this be done?

    Many thanks

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Adding Legend next to lines in Line Chart?
    By johanna0507 in forum Excel Charting & Pivots
    Replies: 5
    Last Post: 11-06-2013, 09:53 AM
  2. Replies: 1
    Last Post: 02-26-2013, 05:56 PM
  3. Adding additional grid lines
    By mknispel in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 01-12-2011, 05:49 AM
  4. adding numbers for multiple text lines
    By nylarising in forum Excel General
    Replies: 6
    Last Post: 11-01-2007, 01:50 PM
  5. Automatically adding Vertical lines after certain points in line graph
    By matthoffman33 in forum Excel Charting & Pivots
    Replies: 4
    Last Post: 03-06-2006, 09:50 PM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1