dose anyone know how i can print something at the top of every page printed in a multi page job? thanks a lot in advance:)
Printable View
dose anyone know how i can print something at the top of every page printed in a multi page job? thanks a lot in advance:)
what are u printing and how are you doin it ?
peet
printer.print "Page" & printer.page
printer.print text1.text
printer.enddoc
srry..posted the code and not the description...i am printing a text box, but it is usually more then 1 page and i am printing it well....that was my code
anyone?:(
think you have to do a lot of coding in order to get this working :(
you would have to calculate how much text from the textbox there is room for on one page, then do a end doc, then print the top text, then as much of the rest text that there is room for ..........
I think the calculation will be a challange.... you will have to find out how to breake words, and you will have to figure out if a LF or a CRLF is beeing used ... lots of things to think about...
then again ... I might be totally wrong :(
peet
but hey! there are lot of smart people on this site, some of you have prob. already done it ??
So common.. share your knowledge with us :)
peet
oooo, guess i will be busy tonight...thnx anyway...
hmmmm, i wonder how long it took em to do in in notepad...something 2 think about!
hmmm ... I'v done this once, but don't get to happy ... I'v used a tool called IT32 (a lot of tools for string man., tables ....) I always use it. But in order for you to see how much code is needed.... here goes :
used the routine this way (part of another routine)Code:Private Function StringSplitter(sFontName As String, dFontSize As Double, bFontBold As Boolean, sTextSomSkalSplittes As String, lColW As Long) As ITTable
Dim t As New ITTable
Dim tOk As New ITTable
Dim i As Integer
Dim j As Integer
Dim currRow As Long
Dim s As String
Dim stmp As String
Dim lLastPos As Long
Dim lLastPosPrev As Long
Dim lCharCount As Long
Dim lStrPos As Long
Dim sRest As String
Dim lDivFakt As Long
Dim iLineCount As Integer
Dim tmpRowPos As Long
Dim currCol As Long
Dim iNumOfSplits As Integer
Dim p As Printer
Set p = Printer
p.FontName = sFontName
p.FontSize = dFontSize
p.FontBold = bFontBold
tOk.Init 1, 1
t.Text = sTextSomSkalSplittes 'Replace(sTextSomSkalSplittes, vbCrLf, vbCr)
Debug.Print t.Text
tmpRowPos = 1
For currRow = 1 To t.Rows
lDivFakt = 1
lLastPosPrev = 0
iLineCount = 0
stmp = Strip(t(currRow, 1), " ", itStripRight)
s = stmp
sRest = stmp
lCharCount = Len(stmp)
lStrPos = Len(stmp)
iNumOfSplits = p.TextWidth(t(currRow, 1)) \ lColW
If iNumOfSplits = 0 Then
tOk(tOk.Rows, 1) = t(currRow, 1)
tOk.InsertRow tOk.Rows + 1
tmpRowPos = tmpRowPos + 1
Else
For j = 1 To iNumOfSplits
If j <> 1 Then
stmp = Mid(s, lLastPosPrev + 1, Len(s) - Len(stmp))
lCharCount = Len(stmp)
lStrPos = Len(stmp)
lLastPos = 0
sRest = stmp
lDivFakt = 1
End If
i = 1
If p.TextWidth(stmp) > lColW Then
While Not (Val(lStrPos - lLastPos) = 1 Or Val(lStrPos - lLastPos) = 0 Or Val(lStrPos - lLastPos) = -1)
lLastPos = lStrPos
i = i + 1
If i <> 1 Then lDivFakt = lDivFakt * 2
If p.TextWidth(stmp) > lColW Then
'for bred
lStrPos = lStrPos - (lCharCount \ lDivFakt)
Else
If p.TextWidth(stmp) = lColW Then
'ok
'MsgBox "OK!"
End If
'for smal
lStrPos = lStrPos + (lCharCount \ lDivFakt)
End If
stmp = Left(sRest, lStrPos)
Wend
If Left(sRest, lStrPos + 1) = " " Then
'dersom neste tegn er et mellomrom, så skal dette ikke & _
taes med i neste delstreng. trenger ikke finne forrige mellomrom, & _
fordi strengen skal deles på mellomrommet som kommer... ehh... det & _
er klart som blekk :)
lStrPos = lStrPos + 2
Else
'må finne første mellomrom til "venstre" i strengen, og starte neste & _
delstreng fra denne.
Dim x As Integer
Dim sChar As String
sChar = ""
x = 0
While sChar <> " "
sChar = Mid(sRest, lStrPos - x, 1)
x = x + 1
'dersom ingen mellomrom ...
If x = lStrPos Then sChar = " "
Wend
If x <> lStrPos Then lStrPos = lStrPos - (x - 1)
End If
stmp = Left(sRest, lStrPos)
lLastPosPrev = lLastPosPrev + lStrPos
End If
'dersom splitting ved foranliggende space, kan antall linjer _
ha økt... dersom økt, må antall splits økes med 1
If (p.TextWidth(Mid(s, lLastPosPrev + 1, Len(s) - Len(stmp))) \ lColW) + j > iNumOfSplits Then
iNumOfSplits = iNumOfSplits + 1
iLineCount = iLineCount + 1
End If
tOk(tmpRowPos, 1) = stmp
tmpRowPos = tmpRowPos + 1
iLineCount = iLineCount + 1
'tOk.InsertRow tOk.Rows + 1
If tmpRowPos > tOk.Rows Then tOk.InsertRow tOk.Rows + 1
Next j
'siste rest av strengen
iLineCount = iLineCount + 1
stmp = Mid(s, lLastPosPrev + 1, Len(s) - Len(stmp))
tOk(tmpRowPos, 1) = stmp
'SplitIT = sResult
tmpRowPos = tmpRowPos + 1
If tmpRowPos > tOk.Rows Then tOk.InsertRow tOk.Rows + 1
End If
Next currRow
Set StringSplitter = tOk
Set tOk = Nothing
End Function
*phu...*Code:Else
'må splitte opp innhold, slik at det passer på utskrift
Set tMultLine = StringSplitter(c.FontName, c.FontSize, c.FontBold, c.Text, c.Width)
For i = 1 To tMultLine.Rows
pobj.CurrentX = c.Left * ZoomFaktX
pobj.Print tMultLine(i, 1)
Next i
End If
a lot of work... but hey.. as I said there is prob. an easier way...
peet
thnx. i will see what i can do...but i am a bit new at this...haha should be fun!
well search the web before jumpin into it "the answer is out there" :)
well if it isn't its a good project...
let me know how it goes.
peet
:p ne1? pls help...i am really stuck here!:p
VB Code:
ss = text1.text LN = Len(ss) Do Until Printer.TextHeight(SS) < Printer.ScaleHeight LN = LN - 1 SS = Mid(SS, 1, LN) Loop FLN = LN Printer.Print SS Printer.EndDoc Printer.NewPage Printer.Print "Whatever I want" LN = Len(ss) Do Until Printer.TextHeight(SS) < Printer.ScaleHeight LN = LN - 1 SS = Mid(SS, FLN, LN) Loop
Foll around with this code. You could make it shorter. I dont have VB Here
Thanks, I think were on the right track now. I am trying to work out the bugs though...i think it will work
it keeps printing 2 copies and one has the header. the other dosent...
What is your final code?
VB Code:
Printer.NewPage Printer.Print "Whatever I want" ss = text1.text LN = Len(ss) Do Until Printer.TextHeight(SS) < Printer.ScaleHeight LN = LN - 1 SS = Mid(Text1.Text, 1, LN) Loop FLN = LN Printer.Print SS Printer.EndDoc NewPge: Printer.NewPage Printer.Print "Whatever I want" LN = Len(ss) Do Until Printer.TextHeight(SS) < Printer.ScaleHeight LN = LN - 1 SS = Mid(Text1.Text, FLN, LN) Loop If LN < Len(SS) Then GoTo NewPge
Try This