Print Preview ActiveX Active Users: 46 / Visits Today: 315
Highest Active Users: 83
Print Preview ActiveX
Home | Profile | Register | Active Topics | Members | Search | FAQ | RSS
Save Password
Forgot your Password?

 All Forums
 Print Preview
 Tips & Tricks
 VB Routine: paraTextList
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic: VB Runtimes and various CAB files Topic Next Topic: VB Code Snippet: fit plain text in area  

Junior Member

113 Posts

Posted - 11/20/2004 :  21:47:22  Show Profile  Visit wbgookin's Homepage  Reply with Quote
I use this routine to make either a numbered or bulleted list out of a paraText. The input is an array with the list items, the x and y coordinates, optionally a width and height to fit the text to, and the type of list. This function requires a couple other's I've posted already. As with the rest, it works for me but your mileage may vary. If you improve it (or any of my routines), please post them here for the rest of us to enjoy!

First is the enum that I use in it:

Public Enum ppListType
    ppLTNumbered = 1
    ppLTBullet = 2
End Enum

And now the routine:

Public Function paraTextList(prn As PrintPreview5.Preview, ByVal valueArray As Variant, xPos As Variant, yPos As Variant, indent As Variant, ByVal listType As ppListType, Optional ByVal fitWidth As Variant, Optional ByVal fitHeight As Variant)
'Function paraTextList (requires paraTextHeight and paraTextFit functions)
'prn is the preview control
'valueArray() is an array filled with the items to be presented in list form
'xPos is the starting x coordinate of the list
'yPos is the starting y coordinate of the list
'listType is of type ppListType (ppLTNumbered or ppLTBullet)
'if supplied, fitWidth and fitHeight are values into which the paratext should be fit.
'paraTextList returns the next y value

Dim i As Integer 'just a counter
Dim txtString As String 'the main string to be printed

txtString = ""
For i = LBound(valueArray) To UBound(valueArray)
    If i > LBound(valueArray) Then txtString = txtString & "<nl>"
    Select Case listType
        Case ppLTNumbered
            txtString = txtString & "<xp -" & prn.C_Twips(indent) & ">" & i & ". <xp 0>" & valueArray(i)
        Case Else 'use a bullet
            txtString = txtString & "<xp -" & prn.C_Twips(indent) & "><ac 149><xp 0>" & valueArray(i)
    End Select
Next i

'if the fitWidth and/or fitHeight variables are missing, use the page width remaining
If IsMissing(fitWidth) Then
    fitWidth = prn.PageWidth - prn.PageMarginLeft - prn.PageMarginRight - prn.C_Twips(xPos)
End If
If IsMissing(fitHeight) Then
    fitHeight = prn.PageHeight - prn.PageMarginTop - prn.PageMarginBottom - prn.C_Twips(yPos)
End If

'use the paratextfit command to fit it into the appropriate area
paraTextList = paraTextFit(prn, txtString, prn.C_Twips(xPos) + prn.C_Twips(indent), yPos, prn.C_Twips(fitWidth) - prn.C_Twips(indent), prn.C_Twips(fitHeight))

End Function

Edited by - wbgookin on 11/20/2004 22:03:06
Go to Bottom of Page
  Previous Topic: VB Runtimes and various CAB files Topic Next Topic: VB Code Snippet: fit plain text in area  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
Print Preview ActiveX © Mandix Go To Top Of Page
This page was generated in 0.06 seconds. Powered By: Snitz Forums 2000 Version 3.4.02