PDA

View Full Version : Graphic problem when I print an excel file into PDF



jungix
06-28-2006, 06:49 AM
Even if on Excel it looks good, sometimes a line is a bit cut in the PDF file that I print. How come it doesn't look the same as the Excel?

Edit: It looks as if the Cells have a maximun size, when the text I want to put in one cell is too long it is cut, and even in Excel I can't increase the size of the cell. How can I do that (I'd need to do it in VBA).

lucas
06-28-2006, 07:31 AM
If it looks ok in Excel print preview then my guess is that it is a setting in your pdf print setup....

jungix
06-28-2006, 07:37 AM
No I've realized inbetween that the text looks too long for the cell. When I select a cell I can see in the fx line the whole text, but in the cell it just stops after 13 lines. Even if I widen the cell (which I can't because of the printing area) the number of lines before the cut decreases and the text is cut as well. Is there a limit in the number of characters or words per cell? How can I do then?

lucas
06-28-2006, 07:47 AM
did you try right click on the cell-click on format cells-select wrap text from the alignment tab? Also it looks like there is a 250 charactor limit....not sure about that.

jungix
06-28-2006, 07:52 AM
Yes I've selected Wrap text, it's not the problem :(

Maybe there's a 256 characters limit

Edit: There's a kb item about it: http://vbaexpress.com/kb/getarticle.php?kb_id=481, but that seems quite complicated and only deals with Excel. Is there not a similar thing written for VBA where you just call it on a cell and it divides it if and only if the text is too long?

jungix
06-28-2006, 01:06 PM
Using the KB code I wrote this, and it cuts the text into several cells, but the last work may be in the middle of a line and there's a white line on the text while I print it in PDF (in excel too by the way). There is no cell inbetween and the text appears good in each cell, but a space remains and it's annoying. Can someone help me?


Public Sub Test()
Dim MyText As String
Dim CellLength As Long, StrLen As Long, j As Long
Dim NextCell As Range
Cells(15, 2).Select
CellLength = 1024
'Analyse text for space preceding cell width and split text
Do
MyText = ActiveCell.Value
StrLen = Len(MyText)
Cells(15, 3) = StrLen
If StrLen > CellLength Then
For j = CellLength To 0 Step -1
If j = 0 Then Exit For
If Mid(MyText, j, 1) = " " Then
ActiveCell.Value = Left(MyText, j)
ActiveCell.Offset(1, 0).Value = Right(MyText, StrLen - j)
Exit For
End If
Next
ActiveCell.Offset(1, 0).Select
End If
Loop Until Len(ActiveCell) <= CellLength
ActiveCell.Offset(1, 0).Select
'Move to right based on MoveAfterEnter
'If Not NextCell Is Nothing Then NextCell.Select

Application.EnableEvents = True

End Sub



Jungix

PS: I tried to edit the title but it doesn't seem to work

mdmackillop
06-28-2006, 02:07 PM
For long text entries, try this KB item
http://vbaexpress.com/kb/getarticle.php?kb_id=421

jungix
06-29-2006, 07:11 AM
Thank you for the link. I tried it and it works almost. I just have 2 little problems:

- I can't set the proper Columnwidth. I don't want a message box each time, so I tried lineIncr = .ColumnWidth-1 (default value of the inbox) and lineIncr = .ColumnWidth but it still doesn't fill the whole line.

- The height of my cell is not right (as said in the KB), and I can't fix it with autofit: Rows("12:12").EntireRow.AutoFit since Autofit sets the height corresponding to the frist 1024 characters. I can increase the height of the cell manually in excell, but I need to do this in the macro to wrap the text.

Any idea on how to do this?

jungix
06-30-2006, 05:30 AM
No one knows how to help me with this? Is there a command to add some height to a cell (I could use it in the loop to increase the height each time I add a line)

mdmackillop
06-30-2006, 09:27 AM
ActiveCell.RowHeight = ActiveCell.RowHeight + 12.5