Visual Basic (VB and VBA)

Copyright 1999-2001 Christopher Greaves. All rights reserved.
Home Page and email to [email protected]
If in doubt, record a macro and inspect the entrails!

 

 

Please read the DISCLAIMER.

Here is an INDEX to all the procedures.

You will probably need one copy of my GLOBAL DECLARATIONS.



'Public Function lngGetTable(strArray, strPath As String, strFile As String, strTable As String) As Long
'' Procedure :   lngGetTable
'' Description:  returns a string array from an Acess97 database table.
'' Copyright: Chris Greaves
'' Inputs:       Database path, file and table name , all as strings.
'' Returns:      The number of rows in the array.
'' Assumes:      None.
'' Side Effects: None.
'' Tested:       By the calls shown below.
'    Dim wrk As Workspace
'    Set wrk = wrkCreateWorkspace("", "admin", "")
'    Dim dbs As Database
'    Set dbs = dbsOpenDatabase(wrk, strPath, strFile) ' given path and file
'    Dim rst As Recordset
'    Set rst = rstOpenRecordset(dbs, "SELECT * from " & strTable) ' given table
'    Dim lngRows As Long
'    rst.MoveLast:     rst.MoveFirst
'    lngRows = rst.RecordCount ' this many records/rows.
'    strArray = rst.GetRows(lngRows)
'    lngGetTable = UBound(strArray, 2)
'    Call CloseRecordset(rst)
'    Call CloseDatabase(dbs)
'    Call wrkCloseWorkspace(wrk)
''Sub TESTlngGetTable()
''    Dim strar
''    Dim lngRows As Long
''    lngRows = lngGetTable(strar, strTemplatePath(), "utilities.mdb", "utilities")
''    MsgBox lngRows
''    MsgBox strar(2, 3)
''End Sub
'End Function
Public Function DeleteBlankRows(rngTbl As Range)
' Procedure :   DeleteBlankRows
' Description:  Delete blank rows of the selected range.
' By:           Chris Greaves Inc.
' Inputs:       RANGE of table.
' Returns:      None
' Assumes:      None.
' Side Effects: The named document contents may change.
' Tested:       By the calls below.
' When we delete elements of a collection, we change the structure of the collection.
'   So, lets loop by row index, backwards from the top
    Dim intRow As Integer
    For intRow = rngTbl.Rows.Count To 1 Step -1
        Dim strText As String
        If boolOnlyWhiteSpace(strTextOfRow(rngTbl.Rows(intRow).Range, rngTbl.Rows(intRow).Range.Cells.Count)) Then
            rngTbl.Rows(intRow).Delete
        Else
        End If
    Next intRow
'Sub TESTDeleteBlankRows()
'Documents.Add
'ActiveDocument.Tables.Add Range:=Selection.Range, NumRows:=8, NumColumns:=8
'Call DeleteBlankRows(Selection.Tables(1).Range)
'End Sub
End Function

We all knew nothing when we started …
Home Page and Contact Information
Send email to [email protected].
This page was last updated Thursday, November 15, 2001

 

 

Hosted by www.Geocities.ws

1

Visual Basic (VB and VBA)

Copyright 1999-2001 Christopher Greaves. All rights reserved.
Home Page and email to [email protected]
If in doubt, record a macro and inspect the entrails!

 

 

Please read the DISCLAIMER.

Here is an INDEX to all the procedures.

You will probably need one copy of my GLOBAL DECLARATIONS.

'Public Function lngGetTable(strArray, strPath As String, strFile As String, strTable As String) As Long
'' Procedure :   lngGetTable
'' Description:  returns a string array from an Acess97 database table.
'' Copyright: Chris Greaves
'' Inputs:       Database path, file and table name , all as strings.
'' Returns:      The number of rows in the array.
'' Assumes:      None.
'' Side Effects: None.
'' Tested:       By the calls shown below.
'    Dim wrk As Workspace
'    Set wrk = wrkCreateWorkspace("", "admin", "")
'    Dim dbs As Database
'    Set dbs = dbsOpenDatabase(wrk, strPath, strFile) ' given path and file
'    Dim rst As Recordset
'    Set rst = rstOpenRecordset(dbs, "SELECT * from " & strTable) ' given table
'    Dim lngRows As Long
'    rst.MoveLast:     rst.MoveFirst
'    lngRows = rst.RecordCount ' this many records/rows.
'    strArray = rst.GetRows(lngRows)
'    lngGetTable = UBound(strArray, 2)
'    Call CloseRecordset(rst)
'    Call CloseDatabase(dbs)
'    Call wrkCloseWorkspace(wrk)
''Sub TESTlngGetTable()
''    Dim strar
''    Dim lngRows As Long
''    lngRows = lngGetTable(strar, strTemplatePath(), "utilities.mdb", "utilities")
''    MsgBox lngRows
''    MsgBox strar(2, 3)
''End Sub
'End Function
Public Function DeleteBlankRows(rngTbl As Range)
' Procedure :   DeleteBlankRows
' Description:  Delete blank rows of the selected range.
' By:           Chris Greaves Inc.
' Inputs:       RANGE of table.
' Returns:      None
' Assumes:      None.
' Side Effects: The named document contents may change.
' Tested:       By the calls below.
' When we delete elements of a collection, we change the structure of the collection.
'   So, lets loop by row index, backwards from the top
    Dim intRow As Integer
    For intRow = rngTbl.Rows.Count To 1 Step -1
        Dim strText As String
        If boolOnlyWhiteSpace(strTextOfRow(rngTbl.Rows(intRow).Range, rngTbl.Rows(intRow).Range.Cells.Count)) Then
            rngTbl.Rows(intRow).Delete
        Else
        End If
    Next intRow
'Sub TESTDeleteBlankRows()
'Documents.Add
'ActiveDocument.Tables.Add Range:=Selection.Range, NumRows:=8, NumColumns:=8
'Call DeleteBlankRows(Selection.Tables(1).Range)
'End Sub
End Function

We all knew nothing when we started …
Home Page and Contact Information
Send email to [email protected].
This page was last updated Thursday, November 15, 2001

 

 

Hosted by www.Geocities.ws

1