Consulting

Results 1 to 10 of 10

Thread: Graphic problem when I print an excel file into PDF

  1. #1
    VBAX Contributor
    Joined
    Jun 2006
    Posts
    135
    Location

    Cut a long text in several cells

    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).
    Last edited by jungix; 06-28-2006 at 11:08 AM.

  2. #2
    Moderator VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    If it looks ok in Excel print preview then my guess is that it is a setting in your pdf print setup....
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

  3. #3
    VBAX Contributor
    Joined
    Jun 2006
    Posts
    135
    Location
    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?

  4. #4
    Moderator VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    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.
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

  5. #5
    VBAX Contributor
    Joined
    Jun 2006
    Posts
    135
    Location
    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?
    Last edited by jungix; 06-28-2006 at 09:05 AM.

  6. #6
    VBAX Contributor
    Joined
    Jun 2006
    Posts
    135
    Location
    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?

    [VBA]
    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

    [/VBA]

    Jungix

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

  7. #7
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    For long text entries, try this KB item
    http://vbaexpress.com/kb/getarticle.php?kb_id=421
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  8. #8
    VBAX Contributor
    Joined
    Jun 2006
    Posts
    135
    Location
    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 [VBA]lineIncr = .ColumnWidth-1 [/VBA] (default value of the inbox) and [VBA]lineIncr = .ColumnWidth[/VBA] 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: [VBA]Rows("12:12").EntireRow.AutoFit[/VBA] 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?

  9. #9
    VBAX Contributor
    Joined
    Jun 2006
    Posts
    135
    Location
    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)

  10. #10
    Administrator
    VP-Knowledge Base VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    [VBA]ActiveCell.RowHeight = ActiveCell.RowHeight + 12.5
    [/VBA]
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •