Print Preview ActiveX Active Users: 62 / Visits Today: 277
Highest Active Users: 110
Print Preview ActiveX
Home | Profile | Register | Active Topics | Members | Search | FAQ | RSS
 All Forums
 Print Preview
 Tips & Tricks
 VB Routine: paraTextHeight

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkInsert Email Insert CodeInsert QuoteInsert List

* Forum Code is ON
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

   Insert a File

Check here to subscribe to this topic.

T O P I C    R E V I E W
wbgookin Posted - 11/20/2004 : 02:31:47
Here's a routine I use to calculate how high a "paraText" will be before I actually print it to the page. It works for me, but your mileage may vary.

Public Function paraTextHeight(prn As PrintPreview5.Preview, paraString As String, paraWidth As Variant) As Long
    'prn is the previously defined preview control
    'paraString is the string you want to send to paraText
    'paraWidth is the width string you want to send to paraText (e.g., "1.2 in")
    'The paraText height as a LONG, based on the given paraWidth.
    'Initialize the paraTextHeight value for return
    paraTextHeight = 0
    'The startX and startY variables are to reset the currentX and currentY values when we're done
    'The startFrame is the frame we have set as the current frame
    Dim startX As Long
    Dim startY As Long
    Dim startFrame As String
    'startFontName and startFontSize are the font information we are starting with
    'we have to reset them with the new frame
    Dim startFontName As String
    Dim startFontSize As Integer
    'The initY and finalY variables will be used to calculate the required height of the paraText
    Dim initY As Long
    Dim finalY As Long
    'Set the startX and startY variables
    startX = prn.CurrentX
    startY = prn.CurrentY
    'Set the startframe = currentFrame, and the startFont = current fontsize
    startFrame = prn.CurrentFrame
    startFontSize = prn.FontSize
    startFontName = prn.FontName
    'Set the current frame to "junkframe"
    prn.AddFrame "junkframe", 0, 0, prn.PageWidth, prn.PageHeight
    prn.CurrentFrame = "junkframe"
    prn.FontName = startFontName
    prn.FontSize = startFontSize
    'Set the initial Y value variable
    initY = prn.CurrentY
    'Print the paraText
    prn.ParaText paraString, , , paraWidth
    'Set the final Y value variable
    finalY = prn.CurrentY
    'Calculate the required height for the paraText
    paraTextHeight = finalY - initY
    'Clear the "junkframe" so our printing doesn't show
    'Set the frame back to the original frame we were in
    prn.CurrentFrame = startFrame
    'Set the currentX and currentY back to what they were at the start
    prn.CurrentX = startX
    prn.CurrentY = startY
    prn.FontName = startFontName
    prn.FontSize = startFontSize
End Function

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